Skip to content

Commit

Permalink
Release leader election lease on exit (#3098)
Browse files Browse the repository at this point in the history
This will make rollouts and restarts much faster.
  • Loading branch information
swiatekm authored Jul 3, 2024
1 parent 239d20c commit 3fc9f8a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .chloggen/feat_drop-lease-on-exit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Release leader election lease on exit

# One or more tracking issues related to the change
issues: [3058]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
16 changes: 9 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,14 @@ func main() {
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "9f7554c3.opentelemetry.io",
LeaseDuration: &leaseDuration,
RenewDeadline: &renewDeadline,
RetryPeriod: &retryPeriod,
PprofBindAddress: pprofAddr,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "9f7554c3.opentelemetry.io",
LeaderElectionReleaseOnCancel: true,
LeaseDuration: &leaseDuration,
RenewDeadline: &renewDeadline,
RetryPeriod: &retryPeriod,
PprofBindAddress: pprofAddr,
WebhookServer: webhook.NewServer(webhook.Options{
Port: webhookPort,
TLSOpts: optionsTlSOptsFuncs,
Expand Down Expand Up @@ -427,6 +428,7 @@ func main() {
}

setupLog.Info("starting manager")
// NOTE: We enable LeaderElectionReleaseOnCancel, and to be safe we need to exit right after the manager does
if err := mgr.Start(ctx); err != nil {
setupLog.Error(err, "problem running manager")
os.Exit(1)
Expand Down

0 comments on commit 3fc9f8a

Please sign in to comment.