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

🐛 util/predicates: log correct object type in cluster predicates #5708

Merged
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
12 changes: 7 additions & 5 deletions util/predicates/cluster_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.
package predicates

import (
"fmt"

"github.com/go-logr/logr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -34,7 +36,7 @@ func ClusterCreateInfraReady(logger logr.Logger) predicate.Funcs {

c, ok := e.Object.(*clusterv1.Cluster)
if !ok {
log.V(4).Info("Expected Cluster", "type", e.Object.GetObjectKind().GroupVersionKind().String())
log.V(4).Info("Expected Cluster", "type", fmt.Sprintf("%T", e.Object))
return false
}
log = log.WithValues("namespace", c.Namespace, "cluster", c.Name)
Expand Down Expand Up @@ -63,7 +65,7 @@ func ClusterCreateNotPaused(logger logr.Logger) predicate.Funcs {

c, ok := e.Object.(*clusterv1.Cluster)
if !ok {
log.V(4).Info("Expected Cluster", "type", e.Object.GetObjectKind().GroupVersionKind().String())
log.V(4).Info("Expected Cluster", "type", fmt.Sprintf("%T", e.Object))
return false
}
log = log.WithValues("namespace", c.Namespace, "cluster", c.Name)
Expand Down Expand Up @@ -92,7 +94,7 @@ func ClusterUpdateInfraReady(logger logr.Logger) predicate.Funcs {

oldCluster, ok := e.ObjectOld.(*clusterv1.Cluster)
if !ok {
log.V(4).Info("Expected Cluster", "type", e.ObjectOld.GetObjectKind().GroupVersionKind().String())
log.V(4).Info("Expected Cluster", "type", fmt.Sprintf("%T", e.ObjectOld))
return false
}
log = log.WithValues("namespace", oldCluster.Namespace, "cluster", oldCluster.Name)
Expand Down Expand Up @@ -122,7 +124,7 @@ func ClusterUpdateUnpaused(logger logr.Logger) predicate.Funcs {

oldCluster, ok := e.ObjectOld.(*clusterv1.Cluster)
if !ok {
log.V(4).Info("Expected Cluster", "type", e.ObjectOld.GetObjectKind().GroupVersionKind().String())
log.V(4).Info("Expected Cluster", "type", fmt.Sprintf("%T", e.ObjectOld))
return false
}
log = log.WithValues("namespace", oldCluster.Namespace, "cluster", oldCluster.Name)
Expand Down Expand Up @@ -212,7 +214,7 @@ func ClusterHasTopology(logger logr.Logger) predicate.Funcs {
func processIfTopologyManaged(logger logr.Logger, object client.Object) bool {
cluster, ok := object.(*clusterv1.Cluster)
if !ok {
logger.V(4).Info("Expected Cluster", "type", object.GetObjectKind().GroupVersionKind().String())
logger.V(4).Info("Expected Cluster", "type", fmt.Sprintf("%T", object))
return false
}

Expand Down