Skip to content

🐛 WIP: Stop cluster/topology reconciliation on Status changes #5956

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

Closed
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
3 changes: 3 additions & 0 deletions internal/controllers/topology/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
ctrlpredicates "sigs.k8s.io/controller-runtime/pkg/predicate"
Copy link
Member

Choose a reason for hiding this comment

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

nit: I wonder if we should use crpredicates instead. I saw cr as prefix in other providers as prefix for controller-runtime and I think it's more intuitive and reads better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whatever suits - I picked ctrl because it's used to import controller runtime itself in other parts of the code, and ctrl client is used in places. We should try to keep the usage consistent if we can.

Copy link
Member

@sbueringer sbueringer Jan 20, 2022

Choose a reason for hiding this comment

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

Yup agree. If nobody else has an opinion on that, let's just leave it as is.
I think currently this would affect:

  • ctrl => sigs.k8s.io/controller-runtime
  • ctrlclient => "sigs.k8s.io/controller-runtime/pkg/client" (which is only very rarely aliased at all, but I don't see a problem there)
  • ctrlpredicates "sigs.k8s.io/controller-runtime/pkg/predicate"

"sigs.k8s.io/controller-runtime/pkg/source"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -77,6 +78,8 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
For(&clusterv1.Cluster{}, builder.WithPredicates(
// Only reconcile Cluster with topology.
predicates.ClusterHasTopology(ctrl.LoggerFrom(ctx)),
// Only reconcile on Cluster Generation change to avoid reconciling on Status updates.
ctrlpredicates.GenerationChangedPredicate{},
Copy link
Member

@sbueringer sbueringer Jan 20, 2022

Choose a reason for hiding this comment

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

Change looks reasonable to me. As far as I'm aware there is no case where we want to reconcile the topology when the status changes.

I think it would be the far more generic solution to the problem, as we then don't have to make sure that every error we propagate into the conditions (which is afaik all of them) is constant with each failed reconcile.

)).
Named("topology/cluster").
Watches(
Expand Down