Skip to content

Commit

Permalink
Release lease when the pod is terminated
Browse files Browse the repository at this point in the history
Closes Azure#4226.
  • Loading branch information
matthchr committed Sep 6, 2024
1 parent b373ec4 commit ba715c7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions v2/cmd/controller/app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ func SetupControllerManager(ctx context.Context, setupLog logr.Logger, flgs *Fla

k8sConfig := ctrl.GetConfigOrDie()
mgr, err := ctrl.NewManager(k8sConfig, ctrl.Options{
Scheme: scheme,
NewCache: cacheFunc,
LeaderElection: flgs.EnableLeaderElection,
LeaderElectionID: "controllers-leader-election-azinfra-generated",
HealthProbeBindAddress: flgs.HealthAddr,
Metrics: getMetricsOpts(flgs),
Scheme: scheme,
NewCache: cacheFunc,
LeaderElection: flgs.EnableLeaderElection,
LeaderElectionID: "controllers-leader-election-azinfra-generated",
// It's only safe to set LeaderElectionReleaseOnCancel to true if the manager binary ends
// when the manager exits. This is the case with us today, so we set this to true to
// enable faster lease transfers.
LeaderElectionReleaseOnCancel: true,
HealthProbeBindAddress: flgs.HealthAddr,
Metrics: getMetricsOpts(flgs),
WebhookServer: webhook.NewServer(webhook.Options{
Port: flgs.WebhookPort,
CertDir: flgs.WebhookCertDir,
Expand Down

0 comments on commit ba715c7

Please sign in to comment.