diff --git a/test/e2e/clusterclass_changes.go b/test/e2e/clusterclass_changes.go index fffc8c6662a5..85f782928d7e 100644 --- a/test/e2e/clusterclass_changes.go +++ b/test/e2e/clusterclass_changes.go @@ -426,7 +426,12 @@ func rebaseClusterClassAndWait(ctx context.Context, input rebaseClusterClassAndW patchHelper, err := patch.NewHelper(input.Cluster, mgmtClient) Expect(err).ToNot(HaveOccurred()) input.Cluster.Spec.Topology.Class = newClusterClassName - Expect(patchHelper.Patch(ctx, input.Cluster)).To(Succeed()) + // We have to retry the patch. The ClusterClass was just created so the client cache in the + // controller/webhook might not be aware of it yet. If the webhook is not aware of the ClusterClass + // we get a "Cluster ... can't be validated. ClusterClass ... can not be retrieved" error. + Eventually(func() error { + return patchHelper.Patch(ctx, input.Cluster) + }, "1m", "5s").Should(Succeed(), "Failed to patch Cluster") log.Logf("Waiting for MachineDeployment rollout to complete.") for _, mdTopology := range input.Cluster.Spec.Topology.Workers.MachineDeployments {