mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #89881 from embano1/etcd-leader-ctx
Add etcd WithRequireLeader option to API watches
This commit is contained in:
commit
3c3fc800df
@ -126,7 +126,15 @@ func (w *watcher) createWatchChan(ctx context.Context, key string, rev int64, re
|
|||||||
// The filter doesn't filter out any object.
|
// The filter doesn't filter out any object.
|
||||||
wc.internalPred = storage.Everything
|
wc.internalPred = storage.Everything
|
||||||
}
|
}
|
||||||
wc.ctx, wc.cancel = context.WithCancel(ctx)
|
|
||||||
|
// The etcd server waits until it cannot find a leader for 3 election
|
||||||
|
// timeouts to cancel existing streams. 3 is currently a hard coded
|
||||||
|
// constant. The election timeout defaults to 1000ms. If the cluster is
|
||||||
|
// healthy, when the leader is stopped, the leadership transfer should be
|
||||||
|
// smooth. (leader transfers its leadership before stopping). If leader is
|
||||||
|
// hard killed, other servers will take an election timeout to realize
|
||||||
|
// leader lost and start campaign.
|
||||||
|
wc.ctx, wc.cancel = context.WithCancel(clientv3.WithRequireLeader(ctx))
|
||||||
return wc
|
return wc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user