From 4d01f767977aceb53acdb131d2cc6a8be987d92e Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Wed, 31 Mar 2021 13:24:36 -0700 Subject: [PATCH] - fix variable validation; - update log level Signed-off-by: Shuting Zhao --- cmd/kyverno/main.go | 2 +- pkg/engine/variables/vars.go | 6 +----- pkg/webhookconfig/registration.go | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cmd/kyverno/main.go b/cmd/kyverno/main.go index 38b87670e0..80044f5005 100755 --- a/cmd/kyverno/main.go +++ b/cmd/kyverno/main.go @@ -308,7 +308,7 @@ func main() { case <-registerTicker.C: err = webhookCfg.Register() if err != nil { - setupLog.Info("Failed to register admission control webhooks") + setupLog.V(3).Info("Failed to register admission control webhooks", "reason", err.Error()) } else { break loop } diff --git a/pkg/engine/variables/vars.go b/pkg/engine/variables/vars.go index 126590e8d2..f5f4752986 100644 --- a/pkg/engine/variables/vars.go +++ b/pkg/engine/variables/vars.go @@ -156,11 +156,7 @@ func substituteVariablesIfAny(log logr.Logger, ctx context.EvalInterface) jsonUt variable = strings.TrimSpace(variable) operation, err := ctx.Query("request.operation") - if err != nil { - return nil, fmt.Errorf("failed to check request.operation") - } - - if operation == "DELETE" { + if err == nil && operation == "DELETE" { variable = strings.ReplaceAll(variable, "request.object", "request.oldObject") } diff --git a/pkg/webhookconfig/registration.go b/pkg/webhookconfig/registration.go index 55f9174ab5..6cb69b6b22 100644 --- a/pkg/webhookconfig/registration.go +++ b/pkg/webhookconfig/registration.go @@ -498,6 +498,6 @@ func (wrc *Register) checkEndpoint() error { } } err = fmt.Errorf("Endpoint not ready") - wrc.log.Error(err, "Endpoint not ready", "ns", config.KyvernoNamespace, "name", config.KyvernoServiceName) + wrc.log.V(3).Info(err.Error(), "ns", config.KyvernoNamespace, "name", config.KyvernoServiceName) return err }