From e695866620846f09196f3fc3c4369423e395a566 Mon Sep 17 00:00:00 2001 From: drivebyer Date: Tue, 29 Oct 2024 15:59:37 +0800 Subject: [PATCH] fix: multi controller run concurrently after leadership lost --- pkg/controller/main-controller.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/controller/main-controller.go b/pkg/controller/main-controller.go index c07a487d77..10c1563c03 100644 --- a/pkg/controller/main-controller.go +++ b/pkg/controller/main-controller.go @@ -569,7 +569,10 @@ func (c *Controller) Start(threadiness int, stopCh <-chan struct{}) error { c.kubeClientSet.CoreV1().Pods(leaseLockNamespace).Patch(ctx, c.podName, types.JSONPatchType, payloadBytes, metav1.PatchOptions{}) } c.Stop() - cancel() + + if err := syscall.Kill(os.Getpid(), syscall.SIGTERM); err != nil { + klog.Errorf("error sending SIGTERM: %v", err) + } }, OnNewLeader: func(identity string) { // we're notified when new leader elected