client-go icon indicating copy to clipboard operation
client-go copied to clipboard

client-go LeaderElector will execute the OnStoppedLeading callback even if it is not a leader

Open believening opened this issue 2 years ago • 0 comments

https://github.com/kubernetes/client-go/blob/1ac8d459351e21458fd1041f41e43403eadcbdba/tools/leaderelection/leaderelection.go#L197-L213

OnStopedLeading and OnStopedElecting are different, should we move the call of OnStopedLeading back?

	if !le.acquire(ctx) {
		return // ctx signalled done
	}
        defer func() {
		le.config.Callbacks.OnStoppedLeading()
	}()

believening avatar Nov 17 '22 08:11 believening