From fb944d599d5487229463478928834cac20963f75 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 7 Jun 2023 20:27:17 +0100 Subject: [PATCH] Fix exit with no error when cert violates lookahead (#2395) Add an exit message when the certificate check triggers a fatal exit (via cancel()). When cancel() is called, this cancels the main context which causes the webhook to shutdown. A return is also added to ensure the message "valid" comes out right after "invalid" like so: "certs are not valid at..." "certs are valid" Signed-off-by: Eric Stokes --- cmd/webhook.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/webhook.go b/cmd/webhook.go index 2d1db31b4..639801e68 100644 --- a/cmd/webhook.go +++ b/cmd/webhook.go @@ -98,7 +98,9 @@ var webhookCmd = &cobra.Command{ setupLog.Info("validating certs") err = crds.CheckCerts(c, dnsName, time.Now().Add(certLookaheadInterval)) if err != nil { + setupLog.Error(err, "certs are not valid at now + lookahead, triggering shutdown", "certLookahead", certLookaheadInterval.String()) cancel() + return } setupLog.Info("certs are valid") }