From cde1d0f2b2cf6241179de5111eacbae54d80712b Mon Sep 17 00:00:00 2001 From: shuting Date: Wed, 19 Jan 2022 00:45:24 +0800 Subject: [PATCH] clean up managed resources when cannot find kyverno deployment (#3018) Signed-off-by: ShutingZhao Co-authored-by: Prateek Pandey --- pkg/webhookconfig/registration.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/webhookconfig/registration.go b/pkg/webhookconfig/registration.go index ed528ea8b1..37a08803f8 100644 --- a/pkg/webhookconfig/registration.go +++ b/pkg/webhookconfig/registration.go @@ -267,6 +267,11 @@ func (wrc *Register) cleanupKyvernoResource() bool { logger := wrc.log.WithName("cleanupKyvernoResource") deploy, err := wrc.client.GetResource("", "Deployment", deployNamespace, deployName) if err != nil { + if errorsapi.IsNotFound(err) { + logger.Info("Kyverno deployment not found, cleanup Kyverno resources") + return true + } + logger.Error(err, "failed to get deployment, not cleaning up kyverno resources") return false }