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

🌱 Move Predicates allow logs to V6 #5148

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
8 changes: 4 additions & 4 deletions util/predicates/cluster_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ClusterCreateInfraReady(logger logr.Logger) predicate.Funcs {

// Only need to trigger a reconcile if the Cluster.Status.InfrastructureReady is true
if c.Status.InfrastructureReady {
log.V(4).Info("Cluster infrastructure is ready, allowing further processing")
log.V(6).Info("Cluster infrastructure is ready, allowing further processing")
return true
}

Expand Down Expand Up @@ -69,7 +69,7 @@ func ClusterCreateNotPaused(logger logr.Logger) predicate.Funcs {

// Only need to trigger a reconcile if the Cluster.Spec.Paused is false
if !c.Spec.Paused {
log.V(4).Info("Cluster is not paused, allowing further processing")
log.V(6).Info("Cluster is not paused, allowing further processing")
return true
}

Expand Down Expand Up @@ -99,7 +99,7 @@ func ClusterUpdateInfraReady(logger logr.Logger) predicate.Funcs {
newCluster := e.ObjectNew.(*clusterv1.Cluster)

if !oldCluster.Status.InfrastructureReady && newCluster.Status.InfrastructureReady {
log.V(4).Info("Cluster infrastructure became ready, allowing further processing")
log.V(6).Info("Cluster infrastructure became ready, allowing further processing")
return true
}

Expand Down Expand Up @@ -129,7 +129,7 @@ func ClusterUpdateUnpaused(logger logr.Logger) predicate.Funcs {
newCluster := e.ObjectNew.(*clusterv1.Cluster)

if oldCluster.Spec.Paused && !newCluster.Spec.Paused {
log.V(4).Info("Cluster was unpaused, allowing further processing")
log.V(6).Info("Cluster was unpaused, allowing further processing")
return true
}

Expand Down
38 changes: 19 additions & 19 deletions util/predicates/generic_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,44 +35,44 @@ func All(logger logr.Logger, predicates ...predicate.Funcs) predicate.Funcs {
log := logger.WithValues("predicateAggregation", "All")
for _, p := range predicates {
if !p.UpdateFunc(e) {
log.V(4).Info("One of the provided predicates returned false, blocking further processing")
log.V(6).Info("One of the provided predicates returned false, blocking further processing")
return false
}
}
log.V(4).Info("All provided predicates returned true, allowing further processing")
log.V(6).Info("All provided predicates returned true, allowing further processing")
return true
},
CreateFunc: func(e event.CreateEvent) bool {
log := logger.WithValues("predicateAggregation", "All")
for _, p := range predicates {
if !p.CreateFunc(e) {
log.V(4).Info("One of the provided predicates returned false, blocking further processing")
log.V(6).Info("One of the provided predicates returned false, blocking further processing")
return false
}
}
log.V(4).Info("All provided predicates returned true, allowing further processing")
log.V(6).Info("All provided predicates returned true, allowing further processing")
return true
},
DeleteFunc: func(e event.DeleteEvent) bool {
log := logger.WithValues("predicateAggregation", "All")
for _, p := range predicates {
if !p.DeleteFunc(e) {
log.V(4).Info("One of the provided predicates returned false, blocking further processing")
log.V(6).Info("One of the provided predicates returned false, blocking further processing")
return false
}
}
log.V(4).Info("All provided predicates returned true, allowing further processing")
log.V(6).Info("All provided predicates returned true, allowing further processing")
return true
},
GenericFunc: func(e event.GenericEvent) bool {
log := logger.WithValues("predicateAggregation", "All")
for _, p := range predicates {
if !p.GenericFunc(e) {
log.V(4).Info("One of the provided predicates returned false, blocking further processing")
log.V(6).Info("One of the provided predicates returned false, blocking further processing")
return false
}
}
log.V(4).Info("All provided predicates returned true, allowing further processing")
log.V(6).Info("All provided predicates returned true, allowing further processing")
return true
},
}
Expand All @@ -85,44 +85,44 @@ func Any(logger logr.Logger, predicates ...predicate.Funcs) predicate.Funcs {
log := logger.WithValues("predicateAggregation", "Any")
for _, p := range predicates {
if p.UpdateFunc(e) {
log.V(4).Info("One of the provided predicates returned true, allowing further processing")
log.V(6).Info("One of the provided predicates returned true, allowing further processing")
return true
}
}
log.V(4).Info("All of the provided predicates returned false, blocking further processing")
log.V(6).Info("All of the provided predicates returned false, blocking further processing")
return false
},
CreateFunc: func(e event.CreateEvent) bool {
log := logger.WithValues("predicateAggregation", "Any")
for _, p := range predicates {
if p.CreateFunc(e) {
log.V(4).Info("One of the provided predicates returned true, allowing further processing")
log.V(6).Info("One of the provided predicates returned true, allowing further processing")
return true
}
}
log.V(4).Info("All of the provided predicates returned false, blocking further processing")
log.V(6).Info("All of the provided predicates returned false, blocking further processing")
return false
},
DeleteFunc: func(e event.DeleteEvent) bool {
log := logger.WithValues("predicateAggregation", "Any")
for _, p := range predicates {
if p.DeleteFunc(e) {
log.V(4).Info("One of the provided predicates returned true, allowing further processing")
log.V(6).Info("One of the provided predicates returned true, allowing further processing")
return true
}
}
log.V(4).Info("All of the provided predicates returned false, blocking further processing")
log.V(6).Info("All of the provided predicates returned false, blocking further processing")
return false
},
GenericFunc: func(e event.GenericEvent) bool {
log := logger.WithValues("predicateAggregation", "Any")
for _, p := range predicates {
if p.GenericFunc(e) {
log.V(4).Info("One of the provided predicates returned true, allowing further processing")
log.V(6).Info("One of the provided predicates returned true, allowing further processing")
return true
}
}
log.V(4).Info("All of the provided predicates returned false, blocking further processing")
log.V(6).Info("All of the provided predicates returned false, blocking further processing")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have misunderstood the PR description, but shouldn't those stay at 4?

My tl;dr was every blocking predicate (i.e. logs in combination with return false) should stay at 4.

Or only a subset of those?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbueringer those are log entry from All and Any, which provides combinations of predicates (the point number 3 in the PR discription); they should be moved at level 6 because they are "echoing" blocking predicates logs from other predicates (they are redundant).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay perfect, thx for the explanation!

return false
},
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func processIfNotPaused(logger logr.Logger, obj client.Object) bool {
log.V(4).Info("Resource is paused, will not attempt to map resource")
return false
}
log.V(4).Info("Resource is not paused, will attempt to map resource")
log.V(6).Info("Resource is not paused, will attempt to map resource")
return true
}

Expand All @@ -203,7 +203,7 @@ func processIfLabelMatch(logger logr.Logger, obj client.Object, labelValue strin
kind := strings.ToLower(obj.GetObjectKind().GroupVersionKind().Kind)
log := logger.WithValues("namespace", obj.GetNamespace(), kind, obj.GetName())
if labels.HasWatchLabel(obj, labelValue) {
log.V(4).Info("Resource matches label, will attempt to map resource")
log.V(6).Info("Resource matches label, will attempt to map resource")
return true
}
log.V(4).Info("Resource does not match label, will not attempt to map resource")
Expand Down Expand Up @@ -238,6 +238,6 @@ func processIfNotExternallyManaged(logger logr.Logger, obj client.Object) bool {
log.V(4).Info("Resource is externally managed, will not attempt to map resource")
return false
}
log.V(4).Info("Resource is managed, will attempt to map resource")
log.V(6).Info("Resource is managed, will attempt to map resource")
return true
}