Skip to content

Commit 66e390e

Browse files
committed
Release Leader Election on Manager Exit
This commit updates the package server manager to voluntarily release it's lease on manager exit which will speed up voluntary leader transition as the new leader doesn't have to wait the LeaseDuration time before taking over. I should note that enabling this setting expects that the binary will immediately exit upon release. Signed-off-by: Alexander Greene <[email protected]>
1 parent f8d481f commit 66e390e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

cmd/package-server-manager/main.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,18 @@ func run(cmd *cobra.Command, args []string) error {
7171

7272
packageserverCSVFields := fields.Set{"metadata.name": name}
7373
mgr, err := ctrl.NewManager(restConfig, manager.Options{
74-
Scheme: setupScheme(),
75-
Namespace: namespace,
76-
MetricsBindAddress: defaultMetricsPort,
77-
LeaderElection: !disableLeaderElection,
78-
LeaderElectionNamespace: namespace,
79-
LeaderElectionID: leaderElectionConfigmapName,
80-
LeaseDuration: &le.LeaseDuration.Duration,
81-
RenewDeadline: &le.RenewDeadline.Duration,
82-
RetryPeriod: &le.RetryPeriod.Duration,
83-
HealthProbeBindAddress: healthCheckAddr,
84-
PprofBindAddress: pprofAddr,
74+
Scheme: setupScheme(),
75+
Namespace: namespace,
76+
MetricsBindAddress: defaultMetricsPort,
77+
LeaderElection: !disableLeaderElection,
78+
LeaderElectionNamespace: namespace,
79+
LeaderElectionID: leaderElectionConfigmapName,
80+
LeaderElectionReleaseOnCancel: true,
81+
LeaseDuration: &le.LeaseDuration.Duration,
82+
RenewDeadline: &le.RenewDeadline.Duration,
83+
RetryPeriod: &le.RetryPeriod.Duration,
84+
HealthProbeBindAddress: healthCheckAddr,
85+
PprofBindAddress: pprofAddr,
8586
Cache: cache.Options{
8687
ByObject: map[client.Object]cache.ByObject{
8788
&olmv1alpha1.ClusterServiceVersion{}: {

0 commit comments

Comments
 (0)