@@ -242,11 +242,9 @@ func patchMachine(ctx context.Context, patchHelper *patch.Helper, machine *clust
242
242
func (r * Reconciler ) reconcile (ctx context.Context , cluster * clusterv1.Cluster , m * clusterv1.Machine ) (ctrl.Result , error ) {
243
243
log := ctrl .LoggerFrom (ctx )
244
244
245
- if conditions .IsTrue (cluster , clusterv1 .ControlPlaneInitializedCondition ) {
246
- if err := r .watchClusterNodes (ctx , cluster ); err != nil {
247
- log .Error (err , "error watching nodes on target cluster" )
248
- return ctrl.Result {}, err
249
- }
245
+ if err := r .watchClusterNodes (ctx , cluster ); err != nil {
246
+ log .Error (err , "error watching nodes on target cluster" )
247
+ return ctrl.Result {}, err
250
248
}
251
249
252
250
// If the Machine belongs to a cluster, add an owner reference.
@@ -687,6 +685,13 @@ func (r *Reconciler) shouldAdopt(m *clusterv1.Machine) bool {
687
685
}
688
686
689
687
func (r * Reconciler ) watchClusterNodes (ctx context.Context , cluster * clusterv1.Cluster ) error {
688
+ log := ctrl .LoggerFrom (ctx )
689
+
690
+ if ! conditions .IsTrue (cluster , clusterv1 .ControlPlaneInitializedCondition ) {
691
+ log .V (5 ).Info ("Skipping node watching setup because control plane is not initialized" )
692
+ return nil
693
+ }
694
+
690
695
// If there is no tracker, don't watch remote nodes
691
696
if r .Tracker == nil {
692
697
return nil
0 commit comments