Skip to content

Commit c2847e8

Browse files
authored
Merge pull request kubernetes#77585 from andyxning/fix_leader_election_start
enhance leader election doc
2 parents 796ecb9 + 95f33ce commit c2847e8

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ limitations under the License.
1616

1717
// Package leaderelection implements leader election of a set of endpoints.
1818
// It uses an annotation in the endpoints object to store the record of the
19-
// election state.
19+
// election state. This implementation does not guarantee that only one
20+
// client is acting as a leader (a.k.a. fencing).
2021
//
21-
// This implementation does not guarantee that only one client is acting as a
22-
// leader (a.k.a. fencing). A client observes timestamps captured locally to
23-
// infer the state of the leader election. Thus the implementation is tolerant
24-
// to arbitrary clock skew, but is not tolerant to arbitrary clock skew rate.
22+
// A client observes timestamps captured locally to infer the state of the
23+
// leader election. Thus the implementation is tolerant to arbitrary clock
24+
// skew, but is not tolerant to arbitrary clock skew rate. Timestamp(renew time)
25+
// is not meaningful if it was collected on another machine. The implementation
26+
// of this client only acts on locally collected timestamps and cannot rely on
27+
// the accuracy of timestamp in the record for correctness.
2528
//
2629
// However the level of tolerance to skew rate can be configured by setting
2730
// RenewDeadline and LeaseDuration appropriately. The tolerance expressed as a
@@ -104,7 +107,15 @@ type LeaderElectionConfig struct {
104107

105108
// LeaseDuration is the duration that non-leader candidates will
106109
// wait to force acquire leadership. This is measured against time of
107-
// last observed ack.
110+
// last observed ack. A client needs to wait a full LeaseDuration without
111+
// observing a change to the record before it can attempt to take over even
112+
// when a client with a different identity against the record's starts and
113+
// the renew time in the record is older than LeaseDuration. A.k.a., when
114+
// all clients are shutdown and after at least a LeaseDuration, clients
115+
// started with different identities against the record's must wait a full
116+
// LeaseDuration before acquiring a lock. Thus LeaseDuration should be as
117+
// short as possible to avoid a possible long waiting. LeaseDuration is 15
118+
// seconds in core Kubernetes components.
108119
LeaseDuration time.Duration
109120
// RenewDeadline is the duration that the acting master will retry
110121
// refreshing leadership before giving up.

0 commit comments

Comments
 (0)