Skip to content

Commit 3722ae2

Browse files
committed
Improve Leader Election Hand Off
This commit introduces a couple of changes to the package server manager to improve hand off between running pods during an upgrade or redeployment. 1. The package server manager will now voluntarily release its lease on manager exit which will speed up voluntary leader transition as the new leader shouldn'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. 2. The package server manager deployment has had its .strategy.type field updated from Rolling to Recreate, which will prevent the new pod from attempting to acquire the lease before the current leader has shutdown and released its lease. Signed-off-by: Alexander Greene <[email protected]>
1 parent f8d481f commit 3722ae2

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
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{}: {

manifests/0000_50_olm_06-psm-operator.deployment.ibm-cloud-managed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
include.release.openshift.io/ibm-cloud-managed: "true"
1010
spec:
1111
strategy:
12-
type: RollingUpdate
12+
type: Recreate
1313
replicas: 1
1414
selector:
1515
matchLabels:

manifests/0000_50_olm_06-psm-operator.deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
include.release.openshift.io/self-managed-high-availability: "true"
1010
spec:
1111
strategy:
12-
type: RollingUpdate
12+
type: Recreate
1313
replicas: 1
1414
selector:
1515
matchLabels:

scripts/generate_crds_manifests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ metadata:
119119
annotations:
120120
spec:
121121
strategy:
122-
type: RollingUpdate
122+
type: Recreate
123123
replicas: 1
124124
selector:
125125
matchLabels:

0 commit comments

Comments
 (0)