Skip to content

Commit 3fc9f8a

Browse files
authored
Release leader election lease on exit (open-telemetry#3098)
This will make rollouts and restarts much faster.
1 parent 239d20c commit 3fc9f8a

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Release leader election lease on exit
9+
10+
# One or more tracking issues related to the change
11+
issues: [3058]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

main.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,14 @@ func main() {
249249
Metrics: metricsserver.Options{
250250
BindAddress: metricsAddr,
251251
},
252-
HealthProbeBindAddress: probeAddr,
253-
LeaderElection: enableLeaderElection,
254-
LeaderElectionID: "9f7554c3.opentelemetry.io",
255-
LeaseDuration: &leaseDuration,
256-
RenewDeadline: &renewDeadline,
257-
RetryPeriod: &retryPeriod,
258-
PprofBindAddress: pprofAddr,
252+
HealthProbeBindAddress: probeAddr,
253+
LeaderElection: enableLeaderElection,
254+
LeaderElectionID: "9f7554c3.opentelemetry.io",
255+
LeaderElectionReleaseOnCancel: true,
256+
LeaseDuration: &leaseDuration,
257+
RenewDeadline: &renewDeadline,
258+
RetryPeriod: &retryPeriod,
259+
PprofBindAddress: pprofAddr,
259260
WebhookServer: webhook.NewServer(webhook.Options{
260261
Port: webhookPort,
261262
TLSOpts: optionsTlSOptsFuncs,
@@ -427,6 +428,7 @@ func main() {
427428
}
428429

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

0 commit comments

Comments
 (0)