Skip to content

Commit ef42618

Browse files
authored
Merge pull request #6336 from alexander-demichev/nodewatchlogs
✨Add logging for machine node watcher
2 parents 6adb3eb + 0849a14 commit ef42618

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
@@ -255,11 +255,9 @@ func patchMachine(ctx context.Context, patchHelper *patch.Helper, machine *clust
255255
func (r *Reconciler) reconcile(ctx context.Context, cluster *clusterv1.Cluster, m *clusterv1.Machine) (ctrl.Result, error) {
256256
log := ctrl.LoggerFrom(ctx)
257257

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
263261
}
264262

265263
// If the Machine belongs to a cluster, add an owner reference.
@@ -748,6 +746,13 @@ func (r *Reconciler) shouldAdopt(m *clusterv1.Machine) bool {
748746
}
749747

750748
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+
751756
// If there is no tracker, don't watch remote nodes
752757
if r.Tracker == nil {
753758
return nil

0 commit comments

Comments
 (0)