Skip to content

Commit c1f70d9

Browse files
committed
hot fix: remove NodeUninitializedTaint from worker nodes once node is initialized by CAPI
1 parent e345160 commit c1f70d9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/controllers/machine/machine_controller_noderef.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
corev1 "k8s.io/api/core/v1"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/klog/v2"
27+
"sigs.k8s.io/cluster-api/internal/util/taints"
2728
ctrl "sigs.k8s.io/controller-runtime"
2829
"sigs.k8s.io/controller-runtime/pkg/client"
2930

@@ -116,6 +117,11 @@ func (r *Reconciler) reconcileNode(ctx context.Context, cluster *clusterv1.Clust
116117
}
117118
}
118119

120+
// Reconcile node taints
121+
if err := r.reconcileNodeTaints(ctx, remoteClient, node); err != nil {
122+
return ctrl.Result{}, errors.Wrapf(err, "failed to reconcile taints on Node %s", klog.KObj(node))
123+
}
124+
119125
// Do the remaining node health checks, then set the node health to true if all checks pass.
120126
status, message := summarizeNodeConditions(node)
121127
if status == corev1.ConditionFalse {
@@ -212,3 +218,17 @@ func (r *Reconciler) getNode(ctx context.Context, c client.Reader, providerID *n
212218

213219
return &nodeList.Items[0], nil
214220
}
221+
222+
func (r *Reconciler) reconcileNodeTaints(ctx context.Context, remoteClient client.Client, node *corev1.Node) error {
223+
patchHelper, err := patch.NewHelper(node, remoteClient)
224+
if err != nil {
225+
return errors.Wrapf(err, "failed to create patch helper for Node %s", klog.KObj(node))
226+
}
227+
// Drop the NodeUninitializedTaint taint on the node.
228+
if taints.RemoveNodeTaint(node, clusterv1.NodeUninitializedTaint) {
229+
if err := patchHelper.Patch(ctx, node); err != nil {
230+
return errors.Wrapf(err, "failed to patch Node %s to modify taints", klog.KObj(node))
231+
}
232+
}
233+
return nil
234+
}

0 commit comments

Comments
 (0)