Skip to content

Commit af811be

Browse files
committed
Don't pick versions that have a replacement as storage version
1 parent d001d56 commit af811be

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

staging/src/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ type introducedInterface interface {
117117
APILifecycleIntroduced() (major, minor int)
118118
}
119119

120+
type replacementInterface interface {
121+
APILifecycleReplacement() schema.GroupVersionKind
122+
}
123+
120124
func emulatedStorageVersion(binaryVersionOfResource schema.GroupVersion, example runtime.Object, effectiveVersion version.EffectiveVersion, scheme *runtime.Scheme) (schema.GroupVersion, error) {
121125
if example == nil || effectiveVersion == nil {
122126
return binaryVersionOfResource, nil
@@ -170,6 +174,14 @@ func emulatedStorageVersion(binaryVersionOfResource schema.GroupVersion, example
170174
// If it was introduced after current compatibility version, don't use it
171175
// skip the introduced check for test when currentVersion is 0.0 to test all apis
172176
if introduced, hasIntroduced := exampleOfGVK.(introducedInterface); hasIntroduced && (compatibilityVersion.Major() > 0 || compatibilityVersion.Minor() > 0) {
177+
178+
// Skip versions that have a replacement.
179+
// This can be used to override this storage version selection by
180+
// marking a storage version has having a replacement and preventing a
181+
// that storage version from being selected.
182+
if _, hasReplacement := exampleOfGVK.(replacementInterface); hasReplacement {
183+
continue
184+
}
173185
// API resource lifecycles should be relative to k8s api version
174186
majorIntroduced, minorIntroduced := introduced.APILifecycleIntroduced()
175187
introducedVer := apimachineryversion.MajorMinor(uint(majorIntroduced), uint(minorIntroduced))

0 commit comments

Comments
 (0)