Skip to content

Commit

Permalink
fix mutate existing force reconciliation
Browse files Browse the repository at this point in the history
Signed-off-by: ShutingZhao <[email protected]>
  • Loading branch information
realshuting committed Dec 20, 2023
1 parent cdd5d4f commit 5dd912c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 0 additions & 4 deletions pkg/policy/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import (

func (pc *policyController) handleMutate(policyKey string, policy kyvernov1.PolicyInterface) error {
logger := pc.log.WithName("handleMutate").WithName(policyKey)
if !policy.GetSpec().MutateExistingOnPolicyUpdate {
logger.V(4).Info("skip policy application on policy event", "policyKey", policyKey, "mutateExiting", policy.GetSpec().MutateExistingOnPolicyUpdate)
return nil
}

logger.Info("update URs on policy event")
for _, rule := range policy.GetSpec().Rules {
Expand Down
8 changes: 3 additions & 5 deletions pkg/policy/policy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ func NewPolicyController(

func (pc *policyController) canBackgroundProcess(p kyvernov1.PolicyInterface) bool {
logger := pc.log.WithValues("policy", p.GetName())
if !p.BackgroundProcessingEnabled() {
if !p.GetSpec().HasGenerate() && !p.GetSpec().IsMutateExisting() {
logger.V(4).Info("background processing is disabled")
return false
}
if !p.GetSpec().HasGenerate() && !p.GetSpec().IsMutateExisting() {
logger.V(4).Info("policy does not have background rules for reconciliation")
return false
}

if err := policyvalidation.ValidateVariables(p, true); err != nil {
Expand Down

0 comments on commit 5dd912c

Please sign in to comment.