@@ -169,6 +169,30 @@ func clusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() cl
169
169
clusterRef ,
170
170
input .E2EConfig .GetIntervals (specName , "wait-cluster" ))
171
171
},
172
+ PostMachinesProvisioned : func () {
173
+ Eventually (func () error {
174
+ // Before running the BeforeClusterUpgrade hook, the topology controller
175
+ // checks if the ControlPlane `IsScaling()` and for MachineDeployments if
176
+ // `IsAnyRollingOut()`.
177
+ // This PostMachineProvisioned function ensures that the clusters machines
178
+ // are healthy by checking the MachineNodeHealthyCondition, so the upgrade
179
+ // below does not get delayed or runs into timeouts before even reaching
180
+ // the BeforeClusterUpgrade hook.
181
+ machineList := & clusterv1.MachineList {}
182
+ if err := input .BootstrapClusterProxy .GetClient ().List (ctx , machineList , client .InNamespace (namespace .Name )); err != nil {
183
+ return errors .Wrap (err , "list machines" )
184
+ }
185
+
186
+ for i := range machineList .Items {
187
+ machine := & machineList .Items [i ]
188
+ if ! conditions .IsTrue (machine , clusterv1 .MachineNodeHealthyCondition ) {
189
+ return errors .Errorf ("machine %q does not have %q condition set to true" , machine .GetName (), clusterv1 .MachineNodeHealthyCondition )
190
+ }
191
+ }
192
+
193
+ return nil
194
+ }, 5 * time .Minute , 15 * time .Second ).Should (Succeed (), "Waiting for rollouts to finish" )
195
+ },
172
196
WaitForClusterIntervals : input .E2EConfig .GetIntervals (specName , "wait-cluster" ),
173
197
WaitForControlPlaneIntervals : input .E2EConfig .GetIntervals (specName , "wait-control-plane" ),
174
198
WaitForMachineDeployments : input .E2EConfig .GetIntervals (specName , "wait-worker-nodes" ),
0 commit comments