Skip to content

Commit 774e747

Browse files
authored
Avoid workload cluster API lookup for controlnodes when it is not ready yet (#973)
Signed-off-by: Adrian Pedriza <[email protected]>
1 parent 58ca74f commit 774e747

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/controller/controlplane/k0s_controlplane_controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,12 @@ func (c *K0sController) reconcileMachines(ctx context.Context, cluster *clusterv
424424
log.Log.Info("Collected machines", "count", activeMachines.Len(), "desired", kcp.Spec.Replicas, "updating", clusterIsUpdating, "deleting", len(machineNamesToDelete), "desiredMachines", desiredMachines.Names())
425425

426426
go func() {
427-
err = c.deleteOldControlNodes(ctx, cluster)
428-
if err != nil {
429-
logger.Error(err, "Error deleting old control nodes")
427+
// The k8s API of the workload cluster must be available to make requests.
428+
if kcp.Status.Ready {
429+
err = c.deleteOldControlNodes(ctx, cluster)
430+
if err != nil {
431+
logger.Error(err, "Error deleting old control nodes")
432+
}
430433
}
431434
}()
432435

0 commit comments

Comments
 (0)