diff --git a/controllers/configurationpolicy_controller.go b/controllers/configurationpolicy_controller.go index 7838abaf..599ab83b 100644 --- a/controllers/configurationpolicy_controller.go +++ b/controllers/configurationpolicy_controller.go @@ -1066,13 +1066,6 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi handled := false // iterate through all namespaces the configurationpolicy is set on for _, ns := range relevantNamespaces { - log.Info( - "Handling the object template for the relevant namespace", - "namespace", ns, - "desiredName", templateObjs[indx].name, - "index", indx, - ) - names, compliant, reason, objKind, related, statusUpdateNeeded := r.handleObjects( objectT, ns, templateObjs[indx], indx, &plc, ) @@ -1090,17 +1083,16 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi names = append([]string{}, templateObjs[indx].name) } + // object template enforced, already handled in handleObjects if names == nil { handled = true } else { enforce = false } - log.Info( - "eupper----- merge", - "names", names, - ) - + // violations for enforce configurationpolicies are already handled in handleObjects, + // so we only need to generate a violation if the remediationAction is set to inform + // Or multiple namespaces and enforce use this if mergeMessageEnforce || (!handled && !enforce) { if !compliant { if len(names) == 0 { @@ -1142,17 +1134,8 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi } } - log.Info( - "outside merge", - "namespacenumber", len(relevantNamespaces), - ) - // In case, when enforce and multiple namespaces, it creates integrated messages, + // When enforce and multiple namespaces, it creates integrated messages, if mergeMessageEnforce { - // In case, when enforce and multiple namespaces, it creates integrated messages, - log.Info( - "inside merge", - ) - parentStatusUpdateNeeded = createMergedStatus( objShouldExist, numCompliant, numNonCompliant, compliantObjects, nonCompliantObjects, &plc, objData, ) @@ -1167,6 +1150,7 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi // createMergedStatus updates the status field for a configurationpolicy with remediationAction=inform // based on how many compliant/noncompliant objects are found when processing the templates in the configurationpolicy +// Or multiple namespaces and enforce use this func createMergedStatus( objShouldExist bool, numCompliant,