mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
Prefer non-alpha storage versions when available
This commit is contained in:
parent
09fa21ab87
commit
af9bf7b41e
@ -169,28 +169,37 @@ func TestEtcdStoragePath(t *testing.T) {
|
|||||||
fixtureFilenameGroup = "core"
|
fixtureFilenameGroup = "core"
|
||||||
}
|
}
|
||||||
// find all versions of this group/kind in all versions of the serialization fixture testdata
|
// find all versions of this group/kind in all versions of the serialization fixture testdata
|
||||||
previousReleaseGroupKindFiles, err := filepath.Glob("../../../staging/src/k8s.io/api/testdata/*/" + fixtureFilenameGroup + ".*." + expectedGVK.Kind + ".yaml")
|
releaseGroupKindFiles, err := filepath.Glob("../../../staging/src/k8s.io/api/testdata/*/" + fixtureFilenameGroup + ".*." + expectedGVK.Kind + ".yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if len(previousReleaseGroupKindFiles) == 0 && !allowMissingTestdataFixtures[expectedGVK] {
|
if len(releaseGroupKindFiles) == 0 && !allowMissingTestdataFixtures[expectedGVK] {
|
||||||
// We should at least find the HEAD fixtures
|
// We should at least find the HEAD fixtures
|
||||||
t.Errorf("No testdata serialization files found for %#v, cannot determine if previous releases could read this group/kind. Add this group-version to k8s.io/api/roundtrip_test.go", expectedGVK)
|
t.Errorf("No testdata serialization files found for %#v, cannot determine if previous releases could read this group/kind. Add this group-version to k8s.io/api/roundtrip_test.go", expectedGVK)
|
||||||
}
|
}
|
||||||
// find non-alpha versions of this group/kind understood by previous releases
|
|
||||||
|
// find non-alpha versions of this group/kind understood by current and previous releases
|
||||||
|
currentNonAlphaVersions := sets.NewString()
|
||||||
previousNonAlphaVersions := sets.NewString()
|
previousNonAlphaVersions := sets.NewString()
|
||||||
for _, previousReleaseGroupKindFile := range previousReleaseGroupKindFiles {
|
for _, previousReleaseGroupKindFile := range releaseGroupKindFiles {
|
||||||
if serverVersion := filepath.Base(filepath.Dir(previousReleaseGroupKindFile)); serverVersion == "HEAD" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
parts := strings.Split(filepath.Base(previousReleaseGroupKindFile), ".")
|
parts := strings.Split(filepath.Base(previousReleaseGroupKindFile), ".")
|
||||||
version := parts[len(parts)-3]
|
version := parts[len(parts)-3]
|
||||||
if !strings.Contains(version, "alpha") {
|
if !strings.Contains(version, "alpha") {
|
||||||
previousNonAlphaVersions.Insert(version)
|
if serverVersion := filepath.Base(filepath.Dir(previousReleaseGroupKindFile)); serverVersion == "HEAD" {
|
||||||
|
currentNonAlphaVersions.Insert(version)
|
||||||
|
} else {
|
||||||
|
previousNonAlphaVersions.Insert(version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(previousNonAlphaVersions) > 0 && !previousNonAlphaVersions.Has(expectedGVK.Version) {
|
if len(currentNonAlphaVersions) > 0 && strings.Contains(expectedGVK.Version, "alpha") {
|
||||||
t.Errorf("Previous releases understand non-alpha versions %q, but do not understand the expected current storage version %q. "+
|
t.Errorf("Non-alpha versions %q exist, but the expected storage version is %q. Prefer beta or GA storage versions over alpha.",
|
||||||
|
currentNonAlphaVersions.List(),
|
||||||
|
expectedGVK.Version,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if !strings.Contains(expectedGVK.Version, "alpha") && len(previousNonAlphaVersions) > 0 && !previousNonAlphaVersions.Has(expectedGVK.Version) {
|
||||||
|
t.Errorf("Previous releases understand non-alpha versions %q, but do not understand the expected current non-alpha storage version %q. "+
|
||||||
"This means a current server will store data in etcd that is not understood by a previous version.",
|
"This means a current server will store data in etcd that is not understood by a previous version.",
|
||||||
previousNonAlphaVersions.List(),
|
previousNonAlphaVersions.List(),
|
||||||
expectedGVK.Version,
|
expectedGVK.Version,
|
||||||
|
Loading…
Reference in New Issue
Block a user