@@ -197,12 +197,27 @@ func UpgradeManagementClusterAndWait(ctx context.Context, input UpgradeManagemen
197197 client := input .ClusterProxy .GetClient ()
198198
199199 if input .ClusterctlBinaryPath != "" {
200- UpgradeWithBinary (ctx , input .ClusterctlBinaryPath , upgradeInput )
200+ clusterctlVersion , err := getClusterCtlVersion (input .ClusterctlBinaryPath )
201+ Expect (err ).ToNot (HaveOccurred ())
202+ upgradeRetries := 1
203+ // Older versions of clusterctl may need to retry the upgrade process to allow for
204+ // cert-manager CAs to become available before continuing. For newer versions of clusterctl
205+ // this is addressed with https://github.com/kubernetes-sigs/cluster-api/pull/10513
206+ if clusterctlVersion .LT (semver .MustParse ("1.7.0" )) {
207+ upgradeRetries = 2
208+ }
209+ for i := range upgradeRetries {
210+ err := UpgradeWithBinary (ctx , input .ClusterctlBinaryPath , upgradeInput )
211+ if err != nil && i < upgradeRetries - 1 {
212+ log .Logf ("Failed to UpgradeWithBinary, retrying: %v" , err )
213+ continue
214+ }
215+ Expect (err ).ToNot (HaveOccurred ())
216+ break
217+ }
201218 // Old versions of clusterctl may deploy CRDs, Mutating- and/or ValidatingWebhookConfigurations
202219 // before creating the new Certificate objects. This check ensures the CA's are up to date before
203220 // continuing.
204- clusterctlVersion , err := getClusterCtlVersion (input .ClusterctlBinaryPath )
205- Expect (err ).ToNot (HaveOccurred ())
206221 if clusterctlVersion .LT (semver .MustParse ("1.7.2" )) {
207222 Eventually (func () error {
208223 return verifyCAInjection (ctx , client )
0 commit comments