Skip to content

Commit 2b6e7e2

Browse files
(kustomize/v1, go/v3) : Add new LeaderElectionReleaseOnCancel as true option commented to let users know when they can use it
1 parent 3f8cb02 commit 2b6e7e2

File tree

11 files changed

+115
-0
lines changed

11 files changed

+115
-0
lines changed

pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/controller_manager_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,14 @@ webhook:
5555
leaderElection:
5656
leaderElect: true
5757
resourceName: {{ hashFNV .Repo }}.{{ .Domain }}
58+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
59+
# when the Manager ends. This requires the binary to immediately end when the
60+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
61+
# speeds up voluntary leader transitions as the new leader don't have to wait
62+
# LeaseDuration time first.
63+
# In the default scaffold provided, the program ends immediately after
64+
# the manager stops, so would be fine to enable this option. However,
65+
# if you are doing or is intended to do any operation such as perform cleanups
66+
# after the manager stops then its usage might be unsafe.
67+
# leaderElectionReleaseOnCancel: true
5868
`

pkg/plugins/golang/v3/scaffolds/internal/templates/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ func main() {
245245
HealthProbeBindAddress: probeAddr,
246246
LeaderElection: enableLeaderElection,
247247
LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}",
248+
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
249+
// when the Manager ends. This requires the binary to immediately end when the
250+
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
251+
// speeds up voluntary leader transitions as the new leader don't have to wait
252+
// LeaseDuration time first.
253+
//
254+
// In the default scaffold provided, the program ends immediately after
255+
// the manager stops, so would be fine to enable this option. However,
256+
// if you are doing or is intended to do any operation such as perform cleanups
257+
// after the manager stops then its usage might be unsafe.
258+
// LeaderElectionReleaseOnCancel: true,
248259
})
249260
{{- else }}
250261
var err error

testdata/project-v3-addon/config/manager/controller_manager_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ webhook:
99
leaderElection:
1010
leaderElect: true
1111
resourceName: 52ea9610.testproject.org
12+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
13+
# when the Manager ends. This requires the binary to immediately end when the
14+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
15+
# speeds up voluntary leader transitions as the new leader don't have to wait
16+
# LeaseDuration time first.
17+
# In the default scaffold provided, the program ends immediately after
18+
# the manager stops, so would be fine to enable this option. However,
19+
# if you are doing or is intended to do any operation such as perform cleanups
20+
# after the manager stops then its usage might be unsafe.
21+
# leaderElectionReleaseOnCancel: true

testdata/project-v3-addon/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ func main() {
7272
HealthProbeBindAddress: probeAddr,
7373
LeaderElection: enableLeaderElection,
7474
LeaderElectionID: "52ea9610.testproject.org",
75+
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
76+
// when the Manager ends. This requires the binary to immediately end when the
77+
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
78+
// speeds up voluntary leader transitions as the new leader don't have to wait
79+
// LeaseDuration time first.
80+
//
81+
// In the default scaffold provided, the program ends immediately after
82+
// the manager stops, so would be fine to enable this option. However,
83+
// if you are doing or is intended to do any operation such as perform cleanups
84+
// after the manager stops then its usage might be unsafe.
85+
// LeaderElectionReleaseOnCancel: true,
7586
})
7687
if err != nil {
7788
setupLog.Error(err, "unable to start manager")

testdata/project-v3-config/config/manager/controller_manager_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ webhook:
99
leaderElection:
1010
leaderElect: true
1111
resourceName: 6858fb70.testproject.org
12+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
13+
# when the Manager ends. This requires the binary to immediately end when the
14+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
15+
# speeds up voluntary leader transitions as the new leader don't have to wait
16+
# LeaseDuration time first.
17+
# In the default scaffold provided, the program ends immediately after
18+
# the manager stops, so would be fine to enable this option. However,
19+
# if you are doing or is intended to do any operation such as perform cleanups
20+
# after the manager stops then its usage might be unsafe.
21+
# leaderElectionReleaseOnCancel: true

testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ webhook:
99
leaderElection:
1010
leaderElect: true
1111
resourceName: 14be1926.testproject.org
12+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
13+
# when the Manager ends. This requires the binary to immediately end when the
14+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
15+
# speeds up voluntary leader transitions as the new leader don't have to wait
16+
# LeaseDuration time first.
17+
# In the default scaffold provided, the program ends immediately after
18+
# the manager stops, so would be fine to enable this option. However,
19+
# if you are doing or is intended to do any operation such as perform cleanups
20+
# after the manager stops then its usage might be unsafe.
21+
# leaderElectionReleaseOnCancel: true

testdata/project-v3-multigroup/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ func main() {
9797
HealthProbeBindAddress: probeAddr,
9898
LeaderElection: enableLeaderElection,
9999
LeaderElectionID: "14be1926.testproject.org",
100+
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
101+
// when the Manager ends. This requires the binary to immediately end when the
102+
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
103+
// speeds up voluntary leader transitions as the new leader don't have to wait
104+
// LeaseDuration time first.
105+
//
106+
// In the default scaffold provided, the program ends immediately after
107+
// the manager stops, so would be fine to enable this option. However,
108+
// if you are doing or is intended to do any operation such as perform cleanups
109+
// after the manager stops then its usage might be unsafe.
110+
// LeaderElectionReleaseOnCancel: true,
100111
})
101112
if err != nil {
102113
setupLog.Error(err, "unable to start manager")

testdata/project-v3-v1beta1/config/manager/controller_manager_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ webhook:
99
leaderElection:
1010
leaderElect: true
1111
resourceName: 2eab85d8.testproject.org
12+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
13+
# when the Manager ends. This requires the binary to immediately end when the
14+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
15+
# speeds up voluntary leader transitions as the new leader don't have to wait
16+
# LeaseDuration time first.
17+
# In the default scaffold provided, the program ends immediately after
18+
# the manager stops, so would be fine to enable this option. However,
19+
# if you are doing or is intended to do any operation such as perform cleanups
20+
# after the manager stops then its usage might be unsafe.
21+
# leaderElectionReleaseOnCancel: true

testdata/project-v3-v1beta1/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ func main() {
7272
HealthProbeBindAddress: probeAddr,
7373
LeaderElection: enableLeaderElection,
7474
LeaderElectionID: "2eab85d8.testproject.org",
75+
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
76+
// when the Manager ends. This requires the binary to immediately end when the
77+
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
78+
// speeds up voluntary leader transitions as the new leader don't have to wait
79+
// LeaseDuration time first.
80+
//
81+
// In the default scaffold provided, the program ends immediately after
82+
// the manager stops, so would be fine to enable this option. However,
83+
// if you are doing or is intended to do any operation such as perform cleanups
84+
// after the manager stops then its usage might be unsafe.
85+
// LeaderElectionReleaseOnCancel: true,
7586
})
7687
if err != nil {
7788
setupLog.Error(err, "unable to start manager")

testdata/project-v3/config/manager/controller_manager_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ webhook:
99
leaderElection:
1010
leaderElect: true
1111
resourceName: dd1da13f.testproject.org
12+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
13+
# when the Manager ends. This requires the binary to immediately end when the
14+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
15+
# speeds up voluntary leader transitions as the new leader don't have to wait
16+
# LeaseDuration time first.
17+
# In the default scaffold provided, the program ends immediately after
18+
# the manager stops, so would be fine to enable this option. However,
19+
# if you are doing or is intended to do any operation such as perform cleanups
20+
# after the manager stops then its usage might be unsafe.
21+
# leaderElectionReleaseOnCancel: true

0 commit comments

Comments
 (0)