Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions cmd/package-server-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import (

"github.com/spf13/cobra"

configv1 "github.com/openshift/api/config/v1"
olmv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"

"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"

ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -71,6 +67,9 @@ func run(cmd *cobra.Command, args []string) error {
LeaderElection: !disableLeaderElection,
LeaderElectionNamespace: namespace,
LeaderElectionID: leaderElectionConfigmapName,
RetryPeriod: timeDurationPtr(defaultRetryPeriod),
RenewDeadline: timeDurationPtr(defaultRenewDeadline),
LeaseDuration: timeDurationPtr(defaultLeaseDuration),
HealthProbeBindAddress: healthCheckAddr,
NewCache: cache.BuilderWithOptions(cache.Options{
SelectorsByObject: cache.SelectorsByObject{
Expand Down Expand Up @@ -114,12 +113,3 @@ func run(cmd *cobra.Command, args []string) error {

return nil
}

func setupScheme() *runtime.Scheme {
scheme := runtime.NewScheme()
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(configv1.Install(scheme))
utilruntime.Must(olmv1alpha1.AddToScheme(scheme))

return scheme
}
35 changes: 35 additions & 0 deletions cmd/package-server-manager/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"time"

configv1 "github.com/openshift/api/config/v1"
olmv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
)

const (
// Note: In order for SNO to GA, controllers need to handle ~60s of API server
// disruptions when attempting to get and sustain leader election:
// - https://github.com/openshift/library-go/pull/1104#discussion_r649313822
// - https://bugzilla.redhat.com/show_bug.cgi?id=1985697
defaultRetryPeriod = 30 * time.Second
defaultRenewDeadline = 60 * time.Second
defaultLeaseDuration = 90 * time.Second
)

func timeDurationPtr(t time.Duration) *time.Duration {
return &t
}

func setupScheme() *runtime.Scheme {
scheme := runtime.NewScheme()
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(configv1.Install(scheme))
utilruntime.Must(olmv1alpha1.AddToScheme(scheme))

return scheme
}