Skip to content

Commit

Permalink
Improve Leader Election Handoff
Browse files Browse the repository at this point in the history
This commit introduces a couple of changes to the package server manager
to improve handoff 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 aquire the lease before the current leader has
shutdown and released its lease.

Signed-off-by: Alexander Greene <greene.al1991@gmail.com>
  • Loading branch information
awgreene committed Aug 30, 2023
1 parent f8d481f commit 17b441e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
23 changes: 12 additions & 11 deletions cmd/package-server-manager/main.go
Expand Up @@ -71,17 +71,18 @@ func run(cmd *cobra.Command, args []string) error {

packageserverCSVFields := fields.Set{"metadata.name": name}
mgr, err := ctrl.NewManager(restConfig, manager.Options{
Scheme: setupScheme(),
Namespace: namespace,
MetricsBindAddress: defaultMetricsPort,
LeaderElection: !disableLeaderElection,
LeaderElectionNamespace: namespace,
LeaderElectionID: leaderElectionConfigmapName,
LeaseDuration: &le.LeaseDuration.Duration,
RenewDeadline: &le.RenewDeadline.Duration,
RetryPeriod: &le.RetryPeriod.Duration,
HealthProbeBindAddress: healthCheckAddr,
PprofBindAddress: pprofAddr,
Scheme: setupScheme(),
Namespace: namespace,
MetricsBindAddress: defaultMetricsPort,
LeaderElection: !disableLeaderElection,
LeaderElectionNamespace: namespace,
LeaderElectionID: leaderElectionConfigmapName,
LeaderElectionReleaseOnCancel: true,
LeaseDuration: &le.LeaseDuration.Duration,
RenewDeadline: &le.RenewDeadline.Duration,
RetryPeriod: &le.RetryPeriod.Duration,
HealthProbeBindAddress: healthCheckAddr,
PprofBindAddress: pprofAddr,
Cache: cache.Options{
ByObject: map[client.Object]cache.ByObject{
&olmv1alpha1.ClusterServiceVersion{}: {
Expand Down
Expand Up @@ -9,7 +9,7 @@ metadata:
include.release.openshift.io/ibm-cloud-managed: "true"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion manifests/0000_50_olm_06-psm-operator.deployment.yaml
Expand Up @@ -9,7 +9,7 @@ metadata:
include.release.openshift.io/self-managed-high-availability: "true"
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_crds_manifests.sh
Expand Up @@ -119,7 +119,7 @@ metadata:
annotations:
spec:
strategy:
type: RollingUpdate
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down

0 comments on commit 17b441e

Please sign in to comment.