1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-01-20 18:52:16 +00:00

feat: add/improve error logs (#11657)

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
This commit is contained in:
Meet Soni 2024-11-25 19:07:43 +05:30 committed by GitHub
parent 9070334df0
commit cf5a5b12ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,13 +90,14 @@ func (e *engine) filterRule(
gvk, subresource := policyContext.ResourceKind() gvk, subresource := policyContext.ResourceKind()
if err := engineutils.MatchesResourceDescription(newResource, rule, admissionInfo, namespaceLabels, policy.GetNamespace(), gvk, subresource, policyContext.Operation()); err != nil { if err := engineutils.MatchesResourceDescription(newResource, rule, admissionInfo, namespaceLabels, policy.GetNamespace(), gvk, subresource, policyContext.Operation()); err != nil {
logger.V(4).Info("new resource does not match...", "reason", err.Error())
if ruleType == engineapi.Generation { if ruleType == engineapi.Generation {
// if the oldResource matched, return "false" to delete GR for it // if the oldResource matched, return "false" to delete GR for it
if err = engineutils.MatchesResourceDescription(oldResource, rule, admissionInfo, namespaceLabels, policy.GetNamespace(), gvk, subresource, policyContext.Operation()); err == nil { if err = engineutils.MatchesResourceDescription(oldResource, rule, admissionInfo, namespaceLabels, policy.GetNamespace(), gvk, subresource, policyContext.Operation()); err == nil {
return engineapi.RuleFail(rule.Name, ruleType, "", rule.ReportProperties) return engineapi.RuleFail(rule.Name, ruleType, "", rule.ReportProperties)
} }
} }
logger.V(4).Info("rule not matched", "reason", err.Error()) logger.V(4).Info("old resource does not match...", "reason", err.Error())
return nil return nil
} }