Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce some noisy logs #166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions controllers/configurationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (r *ConfigurationPolicyReconciler) PeriodicallyExecConfigPolicies(
policyQueue := make(chan *policyv1.ConfigurationPolicy, len(policiesList.Items))
var wg sync.WaitGroup

log.Info("Processing the policies", "count", len(policiesList.Items))
log.V(1).Info("Processing the policies", "count", len(policiesList.Items))

// Initialize the related object map
policyRelatedObjectMap = sync.Map{}
Expand Down Expand Up @@ -490,7 +490,7 @@ func (r *ConfigurationPolicyReconciler) getObjectTemplateDetails(
if selector.MatchLabels == nil && selector.MatchExpressions == nil && len(selector.Include) == 0 {
r.SelectorReconciler.Stop(plc.Name)

log.Info("namespaceSelector is empty. Skipping namespace retrieval.")
log.V(1).Info("namespaceSelector is empty. Skipping namespace retrieval.")
} else {
// If an error occurred in the NamespaceSelector, update the policy status and abort
var err error
Expand Down Expand Up @@ -518,7 +518,7 @@ func (r *ConfigurationPolicyReconciler) getObjectTemplateDetails(
}

if len(selectedNamespaces) == 0 {
log.Info("Fetching namespaces with provided NamespaceSelector returned no namespaces.",
log.V(1).Info("Fetching namespaces with provided NamespaceSelector returned no namespaces.",
"namespaceSelector", fmt.Sprintf("%+v", selector))
}
}
Expand Down Expand Up @@ -775,7 +775,7 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi

err = r.Patch(context.TODO(), &plc, client.RawPatch(types.JSONPatchType, patch))
if err != nil {
log.V(1).Error(err, "Error removing finalizer for configuration policy")
log.Error(err, "Error removing finalizer for configuration policy")

return
}
Expand All @@ -799,31 +799,31 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi

err := r.Patch(context.TODO(), &plc, client.RawPatch(types.JSONPatchType, patch))
if err != nil {
log.V(1).Error(err, "Error setting finalizer for configuration policy")
log.Error(err, "Error setting finalizer for configuration policy")

return
}
}

// kick off object deletion if configurationPolicy has been deleted
if plc.ObjectMeta.DeletionTimestamp != nil {
log.V(1).Info("Config policy has been deleted, handling child objects")
log.Info("Config policy has been deleted, handling child objects")

failures := r.cleanUpChildObjects(plc, nil)

if len(failures) == 0 {
log.V(1).Info("Objects have been successfully cleaned up, removing finalizer")
log.Info("Objects have been successfully cleaned up, removing finalizer")

patch := removeObjFinalizerPatch(&plc, pruneObjectFinalizer)

err = r.Patch(context.TODO(), &plc, client.RawPatch(types.JSONPatchType, patch))
if err != nil {
log.V(1).Error(err, "Error removing finalizer for configuration policy")
log.Error(err, "Error removing finalizer for configuration policy")

return
}
} else {
log.V(1).Info("Object cleanup failed, some objects have not been deleted from the cluster")
log.Info("Object cleanup failed, some objects have not been deleted from the cluster")

statusChanged := addConditionToStatus(
&plc,
Expand Down Expand Up @@ -854,7 +854,7 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi

err := r.Patch(context.TODO(), &plc, client.RawPatch(types.JSONPatchType, patch))
if err != nil {
log.V(1).Error(err, "Error removing finalizer for configuration policy")
log.Error(err, "Error removing finalizer for configuration policy")

return
}
Expand Down Expand Up @@ -1163,7 +1163,7 @@ func (r *ConfigurationPolicyReconciler) handleObjectTemplates(plc policyv1.Confi

// iterate through all namespaces the configurationpolicy is set on
for _, ns := range relevantNamespaces {
log.Info(
log.V(1).Info(
"Handling the object template for the relevant namespace",
"namespace", ns,
"desiredName", templateObjs[indx].name,
Expand Down Expand Up @@ -2748,7 +2748,7 @@ func (r *ConfigurationPolicyReconciler) updatePolicyStatus(
sendEvent bool,
) error {
if sendEvent {
log.V(1).Info("Sending parent policy compliance event")
log.Info("Sending parent policy compliance event")

// If the compliance event can't be created, then don't update the ConfigurationPolicy
// status. As long as that hasn't been updated, everything will be retried next loop.
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func main() {
managerCtx, managerCancel := context.WithCancel(context.Background())

// PeriodicallyExecConfigPolicies is the go-routine that periodically checks the policies
log.V(1).Info("Periodically processing Configuration Policies", "frequency", opts.frequency)
log.Info("Periodically processing Configuration Policies", "frequency", opts.frequency)

go func() {
reconciler.PeriodicallyExecConfigPolicies(terminatingCtx, opts.frequency, mgr.Elected())
Expand Down