From af811be190b7d04a49ecf47bf55a3858fa7e7e96 Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Wed, 30 Oct 2024 11:47:43 -0400 Subject: [PATCH] Don't pick versions that have a replacement as storage version --- .../pkg/server/storage/resource_encoding_config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/staging/src/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go b/staging/src/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go index 271948c147f..ce1bec6763a 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go @@ -117,6 +117,10 @@ type introducedInterface interface { APILifecycleIntroduced() (major, minor int) } +type replacementInterface interface { + APILifecycleReplacement() schema.GroupVersionKind +} + func emulatedStorageVersion(binaryVersionOfResource schema.GroupVersion, example runtime.Object, effectiveVersion version.EffectiveVersion, scheme *runtime.Scheme) (schema.GroupVersion, error) { if example == nil || effectiveVersion == nil { return binaryVersionOfResource, nil @@ -170,6 +174,14 @@ func emulatedStorageVersion(binaryVersionOfResource schema.GroupVersion, example // If it was introduced after current compatibility version, don't use it // skip the introduced check for test when currentVersion is 0.0 to test all apis if introduced, hasIntroduced := exampleOfGVK.(introducedInterface); hasIntroduced && (compatibilityVersion.Major() > 0 || compatibilityVersion.Minor() > 0) { + + // Skip versions that have a replacement. + // This can be used to override this storage version selection by + // marking a storage version has having a replacement and preventing a + // that storage version from being selected. + if _, hasReplacement := exampleOfGVK.(replacementInterface); hasReplacement { + continue + } // API resource lifecycles should be relative to k8s api version majorIntroduced, minorIntroduced := introduced.APILifecycleIntroduced() introducedVer := apimachineryversion.MajorMinor(uint(majorIntroduced), uint(minorIntroduced))