From 9fd59297f8d0ec63669bc57f694b5cdbbb455ecf Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Fri, 19 Jul 2019 17:52:24 -0700 Subject: [PATCH] remove rule name in failure even info --- pkg/engine/mutation.go | 6 +++--- pkg/engine/validation.go | 2 +- pkg/webhooks/mutation.go | 2 +- pkg/webhooks/validation.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/engine/mutation.go b/pkg/engine/mutation.go index 6d5b2b0b32..6c6b9b680b 100644 --- a/pkg/engine/mutation.go +++ b/pkg/engine/mutation.go @@ -29,7 +29,7 @@ func Mutate(policy kubepolicy.Policy, rawResource []byte, gvk metav1.GroupVersio overlayPatches, err := ProcessOverlay(rule, rawResource, gvk) if err != nil { ri.Fail() - ri.Addf("Rule %s: Overlay application has failed, err %s.", rule.Name, err) + ri.Addf("overlay application has failed, err %v.", err) } else { // Apply the JSON patches from the rule to the resource rawResource, err = ApplyPatches(rawResource, overlayPatches) @@ -49,14 +49,14 @@ func Mutate(policy kubepolicy.Policy, rawResource []byte, gvk metav1.GroupVersio if len(errs) > 0 { ri.Fail() for _, err := range errs { - ri.Addf("Rule %s: Patches application has failed, err %s.", rule.Name, err) + ri.Addf("patches application has failed, err %v.", err) } } else { // Apply the JSON patches from the rule to the resource rawResource, err = ApplyPatches(rawResource, rulePatches) if err != nil { ri.Fail() - ri.Addf("Unable to apply JSON patch to resource, err %s.", err) + ri.Addf("Unable to apply JSON patch to resource, err %v.", err) } else { ri.Addf("Rule %s: Patches succesfully applied.", rule.Name) allPatches = append(allPatches, rulePatches...) diff --git a/pkg/engine/validation.go b/pkg/engine/validation.go index 8210f6e609..832feffb35 100644 --- a/pkg/engine/validation.go +++ b/pkg/engine/validation.go @@ -41,7 +41,7 @@ func Validate(policy kubepolicy.Policy, rawResource []byte, gvk metav1.GroupVers err := validateResourceWithPattern(resource, rule.Validation.Pattern) if err != nil { ri.Fail() - ri.Addf("Rule %s: Validation has failed, err %s.", rule.Name, err) + ri.Addf("validation has failed, err %v.", err) } else { ri.Addf("Rule %s: Validation succesfully.", rule.Name) diff --git a/pkg/webhooks/mutation.go b/pkg/webhooks/mutation.go index 9dd39b6bf0..f1e789edf2 100644 --- a/pkg/webhooks/mutation.go +++ b/pkg/webhooks/mutation.go @@ -59,7 +59,7 @@ func (ws *WebhookServer) HandleMutation(request *v1beta1.AdmissionRequest) *v1be if !policyInfo.IsSuccessful() { glog.Infof("Failed to apply policy %s on resource %s/%s", policy.Name, rname, rns) for _, r := range ruleInfos { - glog.Warning(r.Msgs) + glog.Warningf("%s: %s\n", r.Name, r.Msgs) } } else { // // CleanUp Violations if exists diff --git a/pkg/webhooks/validation.go b/pkg/webhooks/validation.go index 51e9dc6071..5c90c92c12 100644 --- a/pkg/webhooks/validation.go +++ b/pkg/webhooks/validation.go @@ -65,7 +65,7 @@ func (ws *WebhookServer) HandleValidation(request *v1beta1.AdmissionRequest) *v1 if !policyInfo.IsSuccessful() { glog.Infof("Failed to apply policy %s on resource %s/%s", policy.Name, rname, rns) for _, r := range ruleInfos { - glog.Warning(r.Msgs) + glog.Warningf("%s: %s\n", r.Name, r.Msgs) } } else { // CleanUp Violations if exists