From 79a7bde4ab64dd93b599cf77e492d0e02789bc59 Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Wed, 13 Nov 2019 18:44:18 -0800 Subject: [PATCH] - fix test; - improve logging --- pkg/policyviolation/controller.go | 2 +- pkg/policyviolation/generator.go | 2 +- pkg/policyviolation/namespacedpv.go | 2 +- pkg/policyviolation/namespacepvcontroller.go | 2 +- test/scenarios/samples/best_practices/add_safe_to_evict.yaml | 4 ---- test/scenarios/samples/best_practices/add_safe_to_evict2.yaml | 4 ---- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/policyviolation/controller.go b/pkg/policyviolation/controller.go index 746e1390aa..869d13ba8c 100644 --- a/pkg/policyviolation/controller.go +++ b/pkg/policyviolation/controller.go @@ -195,7 +195,7 @@ func (pvc *PolicyViolationController) syncPolicyViolation(key string) error { startTime := time.Now() glog.V(4).Infof("Started syncing policy violation %q (%v)", key, startTime) defer func() { - glog.V(4).Infof("Finished syncing policy violation %q (%v)", key, time.Since(startTime)) + glog.V(4).Infof("Finished syncing cluster policy violation %q (%v)", key, time.Since(startTime)) }() policyViolation, err := pvc.pvLister.Get(key) if errors.IsNotFound(err) { diff --git a/pkg/policyviolation/generator.go b/pkg/policyviolation/generator.go index ca3429b478..cd9a715232 100644 --- a/pkg/policyviolation/generator.go +++ b/pkg/policyviolation/generator.go @@ -149,7 +149,7 @@ func (gen *Generator) handleErr(err error, key interface{}) { // retires requests if there is error if gen.queue.NumRequeues(key) < workQueueRetryLimit { - glog.Warningf("Error syncing policy violation %v: %v", key, err) + glog.V(4).Infof("Error syncing policy violation %v: %v", key, err) // Re-enqueue the key rate limited. Based on the rate limiter on the // queue and the re-enqueue history, the key will be processed later again. gen.queue.AddRateLimited(key) diff --git a/pkg/policyviolation/namespacedpv.go b/pkg/policyviolation/namespacedpv.go index cba216400d..2e270a9ad2 100644 --- a/pkg/policyviolation/namespacedpv.go +++ b/pkg/policyviolation/namespacedpv.go @@ -77,7 +77,7 @@ func createNamespacedPV(dclient *dclient.Client, pvLister kyvernolister.Namespac glog.V(4).Infof("creating new namespaced policy violation for policy %s & resource %s", newPv.Spec.Policy, newPv.Spec.ResourceSpec.ToKey()) if err := retryGetResource(dclient, newPv.Spec.ResourceSpec); err != nil { - return fmt.Errorf("failed to get resource for policy violation '%s': %v", curPv.Name, err) + return fmt.Errorf("failed to get resource for policy violation on resource '%s': %v", newPv.Spec.ResourceSpec.ToKey(), err) } if _, err := pvInterface.NamespacedPolicyViolations(newPv.Spec.ResourceSpec.Namespace).Create(&newPv); err != nil { diff --git a/pkg/policyviolation/namespacepvcontroller.go b/pkg/policyviolation/namespacepvcontroller.go index f290dabc09..59e1455807 100644 --- a/pkg/policyviolation/namespacepvcontroller.go +++ b/pkg/policyviolation/namespacepvcontroller.go @@ -187,7 +187,7 @@ func (pvc *NamespacedPolicyViolationController) syncPolicyViolation(key string) startTime := time.Now() glog.V(4).Infof("Started syncing policy violation %q (%v)", key, startTime) defer func() { - glog.V(4).Infof("Finished syncing policy violation %q (%v)", key, time.Since(startTime)) + glog.V(4).Infof("Finished syncing namespaced policy violation %q (%v)", key, time.Since(startTime)) }() // tags: NAMESPACE/NAME diff --git a/test/scenarios/samples/best_practices/add_safe_to_evict.yaml b/test/scenarios/samples/best_practices/add_safe_to_evict.yaml index 435ec26012..c861cf65d4 100644 --- a/test/scenarios/samples/best_practices/add_safe_to_evict.yaml +++ b/test/scenarios/samples/best_practices/add_safe_to_evict.yaml @@ -14,10 +14,6 @@ expected: name: pod-with-emptydir rules: - name: annotate-empty-dir - type: Mutation - success: true - message: "successfully processed overlay" - - name: annotate-host-path type: Mutation success: true message: "successfully processed overlay" \ No newline at end of file diff --git a/test/scenarios/samples/best_practices/add_safe_to_evict2.yaml b/test/scenarios/samples/best_practices/add_safe_to_evict2.yaml index baaf85a961..1ca956c8f7 100644 --- a/test/scenarios/samples/best_practices/add_safe_to_evict2.yaml +++ b/test/scenarios/samples/best_practices/add_safe_to_evict2.yaml @@ -14,10 +14,6 @@ expected: name: pod-with-hostpath rules: - name: annotate-empty-dir - type: Mutation - success: true - message: "successfully processed overlay" - - name: annotate-host-path type: Mutation success: true message: "successfully processed overlay" \ No newline at end of file