From b129ed9e05e7a429bb36e23fac10f2d935f20b0d Mon Sep 17 00:00:00 2001 From: Lionel Villard Date: Wed, 24 Jun 2020 13:26:31 -0400 Subject: [PATCH] apply k8s leader election fix locally --- hack/k8s-client-go.patch | 12 ++++++++++++ hack/update-deps.sh | 5 +++++ .../client-go/tools/leaderelection/leaderelection.go | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 hack/k8s-client-go.patch diff --git a/hack/k8s-client-go.patch b/hack/k8s-client-go.patch new file mode 100644 index 00000000000..a39c2fc0a2a --- /dev/null +++ b/hack/k8s-client-go.patch @@ -0,0 +1,12 @@ +--- vendor/k8s.io/client-go/tools/leaderelection/leaderelection.go 2020-07-02 11:15:19.000000000 -0400 ++++ vendor/k8s.io/client-go/tools/leaderelection/leaderelection_new.go 2020-07-06 15:51:35.000000000 -0400 +@@ -301,7 +301,8 @@ + return true + } + leaderElectionRecord := rl.LeaderElectionRecord{ +- LeaderTransitions: le.observedRecord.LeaderTransitions, ++ LeaderTransitions: le.observedRecord.LeaderTransitions, ++ LeaseDurationSeconds: le.observedRecord.LeaseDurationSeconds, + } + if err := le.config.Lock.Update(leaderElectionRecord); err != nil { + klog.Errorf("Failed to release lock: %v", err) diff --git a/hack/update-deps.sh b/hack/update-deps.sh index 076f6ecbdba..9e01593275b 100755 --- a/hack/update-deps.sh +++ b/hack/update-deps.sh @@ -61,3 +61,8 @@ find vendor/ -name '*_test.go'-delete export GOFLAGS=-mod=vendor update_licenses third_party/VENDOR-LICENSE "./..." + + +# Patch k8s leader-election fixing graceful release +# More information: https://github.com/kubernetes/kubernetes/pull/91942 +patch vendor/k8s.io/client-go/tools/leaderelection/leaderelection.go hack/k8s-client-go.patch diff --git a/vendor/k8s.io/client-go/tools/leaderelection/leaderelection.go b/vendor/k8s.io/client-go/tools/leaderelection/leaderelection.go index 42fffd45ae7..aca8717902e 100644 --- a/vendor/k8s.io/client-go/tools/leaderelection/leaderelection.go +++ b/vendor/k8s.io/client-go/tools/leaderelection/leaderelection.go @@ -301,7 +301,8 @@ func (le *LeaderElector) release() bool { return true } leaderElectionRecord := rl.LeaderElectionRecord{ - LeaderTransitions: le.observedRecord.LeaderTransitions, + LeaderTransitions: le.observedRecord.LeaderTransitions, + LeaseDurationSeconds: le.observedRecord.LeaseDurationSeconds, } if err := le.config.Lock.Update(leaderElectionRecord); err != nil { klog.Errorf("Failed to release lock: %v", err)