Skip to content

Commit

Permalink
Log policy NonCompliance
Browse files Browse the repository at this point in the history
Consistently log the policy noncompliance and compliance as updates are
made. The goal is to allow tools that scrape logs to be able to obtain
the violation message and the details on when compliance changes happen.

Refs:
 - https://issues.redhat.com/browse/ACM-5568

Signed-off-by: Gus Parvin <gparvin@redhat.com>
  • Loading branch information
gparvin authored and openshift-merge-robot committed Aug 9, 2023
1 parent d877c5e commit 73f50ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controllers/configurationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2818,11 +2818,14 @@ func (r *ConfigurationPolicyReconciler) updatePolicyStatus(
eventType = eventWarning
}

eventMessage := fmt.Sprintf("%s%s", policy.Status.ComplianceState, msg)
log.Info("Policy status message", "policy", policy.GetName(), "status", eventMessage)

r.Recorder.Event(
policy,
eventType,
"Policy updated",
fmt.Sprintf("Policy status is %s%s", policy.Status.ComplianceState, msg),
fmt.Sprintf("Policy status is %s", eventMessage),
)
}

Expand Down

0 comments on commit 73f50ce

Please sign in to comment.