Skip to content

Commit 3a21821

Browse files
Merge pull request #136 from timflannagan/update-leader-election-psm-config
Bug 1985697: Update the package-server-manager leader election configuration
2 parents e47245b + 50b71a7 commit 3a21821

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

cmd/package-server-manager/main.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ import (
66

77
"github.com/spf13/cobra"
88

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

1211
"k8s.io/apimachinery/pkg/fields"
13-
"k8s.io/apimachinery/pkg/runtime"
14-
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
15-
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
1612
_ "k8s.io/client-go/plugin/pkg/client/auth"
1713

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

115114
return nil
116115
}
117-
118-
func setupScheme() *runtime.Scheme {
119-
scheme := runtime.NewScheme()
120-
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
121-
utilruntime.Must(configv1.Install(scheme))
122-
utilruntime.Must(olmv1alpha1.AddToScheme(scheme))
123-
124-
return scheme
125-
}

cmd/package-server-manager/util.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package main
2+
3+
import (
4+
"time"
5+
6+
configv1 "github.com/openshift/api/config/v1"
7+
olmv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
8+
9+
"k8s.io/apimachinery/pkg/runtime"
10+
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
11+
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
12+
)
13+
14+
const (
15+
// Note: In order for SNO to GA, controllers need to handle ~60s of API server
16+
// disruptions when attempting to get and sustain leader election:
17+
// - https://github.com/openshift/library-go/pull/1104#discussion_r649313822
18+
// - https://bugzilla.redhat.com/show_bug.cgi?id=1985697
19+
defaultRetryPeriod = 30 * time.Second
20+
defaultRenewDeadline = 60 * time.Second
21+
defaultLeaseDuration = 90 * time.Second
22+
)
23+
24+
func timeDurationPtr(t time.Duration) *time.Duration {
25+
return &t
26+
}
27+
28+
func setupScheme() *runtime.Scheme {
29+
scheme := runtime.NewScheme()
30+
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
31+
utilruntime.Must(configv1.Install(scheme))
32+
utilruntime.Must(olmv1alpha1.AddToScheme(scheme))
33+
34+
return scheme
35+
}

0 commit comments

Comments
 (0)