1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

fix(background-controller): reduce logging for URs (#11616)

Signed-off-by: Frederic Mereu <frederic.mereu@gaming1.com>
This commit is contained in:
Frederic M 2024-11-18 14:22:26 +01:00 committed by GitHub
parent 3137cb6e0a
commit 5e79e5044a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -22,7 +22,7 @@ import (
func (pc *policyController) handleGenerate(policyKey string, policy kyvernov1.PolicyInterface) error { func (pc *policyController) handleGenerate(policyKey string, policy kyvernov1.PolicyInterface) error {
logger := pc.log.WithName("handleGenerate").WithName(policyKey) logger := pc.log.WithName("handleGenerate").WithName(policyKey)
logger.Info("update URs on policy event") logger.V(4).Info("update URs on policy event")
if err := pc.syncDataPolicyChanges(policy, false); err != nil { if err := pc.syncDataPolicyChanges(policy, false); err != nil {
logger.Error(err, "failed to create UR on policy event") logger.Error(err, "failed to create UR on policy event")
@ -65,7 +65,7 @@ func (pc *policyController) syncDataPolicyChanges(policy kyvernov1.PolicyInterfa
if len(ur.Spec.RuleContext) == 0 { if len(ur.Spec.RuleContext) == 0 {
return multierr.Combine(errs...) return multierr.Combine(errs...)
} }
pc.log.V(2).WithName("syncDataPolicyChanges").Info("creating new UR for generate") pc.log.V(4).WithName("syncDataPolicyChanges").Info("creating new UR for generate")
created, err := pc.urGenerator.Generate(context.TODO(), pc.kyvernoClient, ur, pc.log) created, err := pc.urGenerator.Generate(context.TODO(), pc.kyvernoClient, ur, pc.log)
if err != nil { if err != nil {
errs = append(errs, err) errs = append(errs, err)
@ -124,7 +124,7 @@ func (pc *policyController) handleGenerateForExisting(policy kyvernov1.PolicyInt
return multierr.Combine(errors...) return multierr.Combine(errors...)
} }
logger.V(2).Info("creating new UR for generate") logger.V(4).Info("creating new UR for generate")
created, err := pc.urGenerator.Generate(context.TODO(), pc.kyvernoClient, ur, pc.log) created, err := pc.urGenerator.Generate(context.TODO(), pc.kyvernoClient, ur, pc.log)
if err != nil { if err != nil {
errors = append(errors, err) errors = append(errors, err)
@ -181,7 +181,7 @@ func (pc *policyController) createURForDownstreamDeletion(policy kyvernov1.Polic
return multierr.Combine(errs...) return multierr.Combine(errs...)
} }
pc.log.V(2).WithName("createURForDownstreamDeletion").Info("creating new UR for generate") pc.log.V(4).WithName("createURForDownstreamDeletion").Info("creating new UR for generate")
created, err := pc.urGenerator.Generate(context.TODO(), pc.kyvernoClient, ur, pc.log) created, err := pc.urGenerator.Generate(context.TODO(), pc.kyvernoClient, ur, pc.log)
if err != nil { if err != nil {
errs = append(errs, err) errs = append(errs, err)

View file

@ -12,7 +12,7 @@ import (
func (pc *policyController) handleMutate(policyKey string, policy kyvernov1.PolicyInterface) error { func (pc *policyController) handleMutate(policyKey string, policy kyvernov1.PolicyInterface) error {
logger := pc.log.WithName("handleMutate").WithName(policyKey) logger := pc.log.WithName("handleMutate").WithName(policyKey)
logger.Info("update URs on policy event") logger.V(4).Info("update URs on policy event")
ruleType := kyvernov2.Mutate ruleType := kyvernov2.Mutate
spec := policy.GetSpec() spec := policy.GetSpec()
@ -42,7 +42,7 @@ func (pc *policyController) handleMutate(policyKey string, policy kyvernov1.Poli
continue continue
} }
logger.Info("creating new UR for mutate") logger.V(4).Info("creating new UR for mutate")
ur := newMutateUR(policy, backgroundcommon.ResourceSpecFromUnstructured(*trigger), rule.Name) ur := newMutateUR(policy, backgroundcommon.ResourceSpecFromUnstructured(*trigger), rule.Name)
skip, err := pc.handleUpdateRequest(ur, trigger, rule.Name, policyNew) skip, err := pc.handleUpdateRequest(ur, trigger, rule.Name, policyNew)
if err != nil { if err != nil {