Skip to content

Commit aafebd8

Browse files
authored
Merge pull request #12003 from k8s-infra-cherrypick-robot/cherry-pick-11984-to-release-1.9
[release-1.9] 🐛 clusterctl upgrade hangs for a time on CRD migration when new version contains a number of new CRDs
2 parents fb30418 + 2fd50cd commit aafebd8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cmd/clusterctl/client/cluster/crd_migration.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,21 @@ func (m *crdMigrator) run(ctx context.Context, newCRD *apiextensionsv1.CustomRes
9191

9292
// Get the current CRD.
9393
currentCRD := &apiextensionsv1.CustomResourceDefinition{}
94+
crdNotFound := false
9495
if err := retryWithExponentialBackoff(ctx, newReadBackoff(), func(ctx context.Context) error {
95-
return m.Client.Get(ctx, client.ObjectKeyFromObject(newCRD), currentCRD)
96-
}); err != nil {
97-
// Return if the CRD doesn't exist yet. We only have to migrate if the CRD exists already.
96+
err := m.Client.Get(ctx, client.ObjectKeyFromObject(newCRD), currentCRD)
9897
if apierrors.IsNotFound(err) {
99-
return false, nil
98+
crdNotFound = true
99+
return nil
100100
}
101+
return err
102+
}); err != nil {
101103
return false, err
102104
}
105+
// Return if the CRD doesn't exist yet. We only have to migrate if the CRD exists already.
106+
if crdNotFound {
107+
return false, nil
108+
}
103109

104110
// Get the storage version of the current CRD.
105111
currentStorageVersion, err := storageVersionForCRD(currentCRD)

0 commit comments

Comments
 (0)