From eb6ab9d2d84f14f0f331ed3ef70ec0eebe0dafda Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Thu, 26 Dec 2019 19:05:12 -0800 Subject: [PATCH] fix rule mis-application --- pkg/engine/mutation.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/engine/mutation.go b/pkg/engine/mutation.go index 3679ac3ad6..ba0ca3fa64 100644 --- a/pkg/engine/mutation.go +++ b/pkg/engine/mutation.go @@ -94,6 +94,11 @@ func Mutate(policyContext PolicyContext) (resp response.EngineResponse) { // insert annotation to podtemplate if resource is pod controller if strings.Contains(PodControllers, resource.GetKind()) { + ann := resource.GetAnnotations() + if _, ok := ann[PodControllersAnnotation]; !ok { + continue + } + var ruleResponse response.RuleResponse ruleResponse, patchedResource = processOverlay(ctx, podTemplateRule, patchedResource) if !ruleResponse.Success {