From bd64cc4d7509fa819ff0246b0077cfd9f5aa9031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Tue, 1 Nov 2022 10:28:20 +0000 Subject: [PATCH] feat: run leader election in loop (#5173) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Signed-off-by: Charles-Edouard Brétéché Co-authored-by: Vyankatesh Kudtarkar --- cmd/kyverno/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/kyverno/main.go b/cmd/kyverno/main.go index 6e7fb495b5..1078747ab6 100644 --- a/cmd/kyverno/main.go +++ b/cmd/kyverno/main.go @@ -723,7 +723,14 @@ func main() { controller.run(signalCtx, logger.WithName("controllers"), &wg) } // start leader election - go le.Run(signalCtx) + go func() { + select { + case <-signalCtx.Done(): + return + default: + le.Run(signalCtx) + } + }() // create webhooks server urgen := webhookgenerate.NewGenerator( kyvernoClient,