@@ -245,6 +245,14 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
245245 return selfHostedClusterProxy .GetClient ().Get (ctx , client.ObjectKey {Name : "kube-system" }, kubeSystem )
246246 }, "5s" , "100ms" ).Should (BeNil (), "Failed to assert self-hosted API server stability" )
247247
248+ By ("Ensure all machines have NodeRef before doing move" )
249+ // Ensure all machines have NodeRef before attempting to move.
250+ // This prevents clusterctl move failures when machines are still provisioning.
251+ framework .WaitForClusterMachineNodeRefs (ctx , framework.WaitForClusterMachineNodeRefsInput {
252+ GetLister : input .BootstrapClusterProxy .GetClient (),
253+ Cluster : cluster ,
254+ }, input .E2EConfig .GetIntervals (specName , "wait-machine-upgrade" )... )
255+
248256 // Get the machines of the workloadCluster before it is moved to become self-hosted to make sure that the move did not trigger
249257 // any unexpected rollouts.
250258 preMoveMachineList := & unstructured.UnstructuredList {}
@@ -447,6 +455,14 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
447455 return selfHostedClusterProxy .GetClient ().Get (ctx , client.ObjectKey {Name : "kube-system" }, kubeSystem )
448456 }, "5s" , "100ms" ).Should (BeNil (), "Failed to assert self-hosted API server stability" )
449457
458+ By ("Ensure all machines have NodeRef before doing move back" )
459+ // Ensure all machines have NodeRef before attempting to move back to bootstrap.
460+ // This prevents clusterctl move failures when machines are still provisioning.
461+ framework .WaitForClusterMachineNodeRefs (ctx , framework.WaitForClusterMachineNodeRefsInput {
462+ GetLister : selfHostedClusterProxy .GetClient (),
463+ Cluster : selfHostedCluster ,
464+ }, input .E2EConfig .GetIntervals (specName , "wait-machine-upgrade" )... )
465+
450466 By ("Moving the cluster back to bootstrap" )
451467 clusterctl .Move (ctx , clusterctl.MoveInput {
452468 LogFolder : filepath .Join (input .ArtifactFolder , "clusters" , clusterResources .Cluster .Name ),
0 commit comments