Skip to content

Commit

Permalink
Add watches for infras and control plane in topology controller
Browse files Browse the repository at this point in the history
Fixes #5194
  • Loading branch information
enxebre committed Sep 8, 2021
1 parent 68e828f commit c770239
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions controllers/topology/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ func (r *ClusterReconciler) reconcile(ctx context.Context, s *scope.Scope) (ctrl
return ctrl.Result{}, errors.Wrap(err, "error reading current state of the Cluster topology")
}

// Watch Infrastructure and ControlPlane CRs when they exist.
if s.Current.InfrastructureCluster != nil {
if err := r.externalTracker.Watch(ctrl.LoggerFrom(ctx), s.Current.InfrastructureCluster,
&handler.EnqueueRequestForOwner{OwnerType: &clusterv1.Cluster{}}); err != nil {
return ctrl.Result{}, errors.Wrap(err, "error watching Infrastructure CR")
}
}
if s.Current.ControlPlane.Object != nil {
if err := r.externalTracker.Watch(ctrl.LoggerFrom(ctx), s.Current.ControlPlane.Object,
&handler.EnqueueRequestForOwner{OwnerType: &clusterv1.Cluster{}}); err != nil {
return ctrl.Result{}, errors.Wrap(err, "error watching ControlPlane CR")
}
}

// Computes the desired state of the Cluster and store it in the request scope.
s.Desired, err = r.computeDesiredState(ctx, s)
if err != nil {
Expand Down

0 comments on commit c770239

Please sign in to comment.