Skip to content

Commit 0849a14

Browse files
Add logging for machine node watcher
1 parent 89a1613 commit 0849a14

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

internal/controllers/machine/machine_controller.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,9 @@ func patchMachine(ctx context.Context, patchHelper *patch.Helper, machine *clust
242242
func (r *Reconciler) reconcile(ctx context.Context, cluster *clusterv1.Cluster, m *clusterv1.Machine) (ctrl.Result, error) {
243243
log := ctrl.LoggerFrom(ctx)
244244

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
250248
}
251249

252250
// If the Machine belongs to a cluster, add an owner reference.
@@ -687,6 +685,13 @@ func (r *Reconciler) shouldAdopt(m *clusterv1.Machine) bool {
687685
}
688686

689687
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+
690695
// If there is no tracker, don't watch remote nodes
691696
if r.Tracker == nil {
692697
return nil

0 commit comments

Comments
 (0)