Skip to content

Commit 196828e

Browse files
authored
Merge pull request #1903 from FillZpp/fix-LeaderElectionResourceLock-doc
📖 Fix comment on LeaderElectionResourceLock
2 parents 4e6a39f + e4e13b9 commit 196828e

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

pkg/manager/manager.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,36 @@ type Options struct {
142142
LeaderElection bool
143143

144144
// LeaderElectionResourceLock determines which resource lock to use for leader election,
145-
// defaults to "configmapsleases". Change this value only if you know what you are doing.
146-
// Otherwise, users of your controller might end up with multiple running instances that
145+
// defaults to "leases". Change this value only if you know what you are doing.
146+
//
147+
// If you are using `configmaps`/`endpoints` resource lock and want to migrate to "leases",
148+
// you might do so by migrating to the respective multilock first ("configmapsleases" or "endpointsleases"),
149+
// which will acquire a leader lock on both resources.
150+
// After all your users have migrated to the multilock, you can go ahead and migrate to "leases".
151+
// Please also keep in mind, that users might skip versions of your controller.
152+
//
153+
// Note: before controller-runtime version v0.7, it was set to "configmaps".
154+
// And from v0.7 to v0.11, the default was "configmapsleases", which was
155+
// used to migrate from configmaps to leases.
156+
// Since the default was "configmapsleases" for over a year, spanning five minor releases,
157+
// any actively maintained operators are very likely to have a released version that uses
158+
// "configmapsleases". Therefore defaulting to "leases" should be safe since v0.12.
159+
//
160+
// So, what do you have to do when you are updating your controller-runtime dependency
161+
// from a lower version to v0.12 or newer?
162+
// - If your operator matches at least one of these conditions:
163+
// - the LeaderElectionResourceLock in your operator has already been explicitly set to "leases"
164+
// - the old controller-runtime version is between v0.7.0 and v0.11.x and the
165+
// LeaderElectionResourceLock wasn't set or was set to "leases"/"configmapsleases"/"endpointsleases"
166+
// feel free to update controller-runtime to v0.12 or newer.
167+
// - Otherwise, you may have to take these steps:
168+
// 1. update controller-runtime to v0.12 or newer in your go.mod
169+
// 2. set LeaderElectionResourceLock to "configmapsleases" (or "endpointsleases")
170+
// 3. package your operator and upgrade it in all your clusters
171+
// 4. only if you have finished 3, you can remove the LeaderElectionResourceLock to use the default "leases"
172+
// Otherwise, your operator might end up with multiple running instances that
147173
// each acquired leadership through different resource locks during upgrades and thus
148174
// act on the same resources concurrently.
149-
// If you want to migrate to the "leases" resource lock, you might do so by migrating to the
150-
// respective multilock first ("configmapsleases" or "endpointsleases"), which will acquire a
151-
// leader lock on both resources. After all your users have migrated to the multilock, you can
152-
// go ahead and migrate to "leases". Please also keep in mind, that users might skip versions
153-
// of your controller.
154-
//
155-
// Note: before controller-runtime version v0.7, the resource lock was set to "configmaps".
156-
// Please keep this in mind, when planning a proper migration path for your controller.
157175
LeaderElectionResourceLock string
158176

159177
// LeaderElectionNamespace determines the namespace in which the leader

0 commit comments

Comments
 (0)