Skip to content

Commit

Permalink
Merge pull request #5221 from enxebre/watches-infra-cp
Browse files Browse the repository at this point in the history
🐛 Add watches for infras and control plane in topology controller
  • Loading branch information
k8s-ci-robot authored Sep 15, 2021
2 parents f8c3205 + b0e96ad commit 04e1ddf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions controllers/topology/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,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 04e1ddf

Please sign in to comment.