@@ -255,11 +255,9 @@ func patchMachine(ctx context.Context, patchHelper *patch.Helper, machine *clust
255
255
func (r * Reconciler ) reconcile (ctx context.Context , cluster * clusterv1.Cluster , m * clusterv1.Machine ) (ctrl.Result , error ) {
256
256
log := ctrl .LoggerFrom (ctx )
257
257
258
- if conditions .IsTrue (cluster , clusterv1 .ControlPlaneInitializedCondition ) {
259
- if err := r .watchClusterNodes (ctx , cluster ); err != nil {
260
- log .Error (err , "error watching nodes on target cluster" )
261
- return ctrl.Result {}, err
262
- }
258
+ if err := r .watchClusterNodes (ctx , cluster ); err != nil {
259
+ log .Error (err , "error watching nodes on target cluster" )
260
+ return ctrl.Result {}, err
263
261
}
264
262
265
263
// If the Machine belongs to a cluster, add an owner reference.
@@ -748,6 +746,13 @@ func (r *Reconciler) shouldAdopt(m *clusterv1.Machine) bool {
748
746
}
749
747
750
748
func (r * Reconciler ) watchClusterNodes (ctx context.Context , cluster * clusterv1.Cluster ) error {
749
+ log := ctrl .LoggerFrom (ctx )
750
+
751
+ if ! conditions .IsTrue (cluster , clusterv1 .ControlPlaneInitializedCondition ) {
752
+ log .V (5 ).Info ("Skipping node watching setup because control plane is not initialized" )
753
+ return nil
754
+ }
755
+
751
756
// If there is no tracker, don't watch remote nodes
752
757
if r .Tracker == nil {
753
758
return nil
0 commit comments