Skip to content

Commit b1c0044

Browse files
authored
Merge pull request #8044 from sbueringer/pr-machine-controller-envtest
🌱 Move machine controller tests to envtest, drop disableNodeLabelSync
2 parents 4f1483e + 58c5874 commit b1c0044

File tree

4 files changed

+422
-404
lines changed

4 files changed

+422
-404
lines changed

internal/controllers/machine/machine_controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ type Reconciler struct {
9191
// nodeDeletionRetryTimeout determines how long the controller will retry deleting a node
9292
// during a single reconciliation.
9393
nodeDeletionRetryTimeout time.Duration
94-
95-
// disableNodeLabelSync should only be used for tests. This is used to skip the parts of
96-
// the controller that need SSA as the current test setup does not support SSA.
97-
// This flag should be dropped after the tests are migrated to envtest.
98-
disableNodeLabelSync bool
9994
}
10095

10196
func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {

internal/controllers/machine/machine_controller_noderef.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,13 @@ func (r *Reconciler) reconcileNode(ctx context.Context, cluster *clusterv1.Clust
124124
}
125125
}
126126

127-
if !r.disableNodeLabelSync {
128-
options := []client.PatchOption{
129-
client.FieldOwner("capi-machine"),
130-
client.ForceOwnership,
131-
}
132-
nodePatch := unstructuredNode(node.Name, node.UID, getManagedLabels(machine.Labels))
133-
if err := remoteClient.Patch(ctx, nodePatch, client.Apply, options...); err != nil {
134-
return ctrl.Result{}, errors.Wrap(err, "failed to apply patch label to the node")
135-
}
127+
options := []client.PatchOption{
128+
client.FieldOwner("capi-machine"),
129+
client.ForceOwnership,
130+
}
131+
nodePatch := unstructuredNode(node.Name, node.UID, getManagedLabels(machine.Labels))
132+
if err := remoteClient.Patch(ctx, nodePatch, client.Apply, options...); err != nil {
133+
return ctrl.Result{}, errors.Wrap(err, "failed to apply patch label to the node")
136134
}
137135

138136
// Do the remaining node health checks, then set the node health to true if all checks pass.

0 commit comments

Comments
 (0)