Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump DefaultKubeBinaryVersion to 1.33 #128279

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
func TestServerRunOptionsValidate(t *testing.T) {
testRegistry := featuregate.NewComponentGlobalsRegistry()
featureGate := utilfeature.DefaultFeatureGate.DeepCopy()
effectiveVersion := utilversion.NewEffectiveVersion("1.30")
effectiveVersion.SetEmulationVersion(version.MajorMinor(1, 32))
effectiveVersion := utilversion.NewEffectiveVersion("1.35")
effectiveVersion.SetEmulationVersion(version.MajorMinor(1, 31))
testComponent := "test"
utilruntime.Must(testRegistry.Register(testComponent, effectiveVersion, featureGate))

Expand Down Expand Up @@ -197,7 +197,7 @@ func TestServerRunOptionsValidate(t *testing.T) {
ComponentName: testComponent,
ComponentGlobalsRegistry: testRegistry,
},
expectErr: "emulation version 1.32 is not between [1.29, 1.30.0]",
expectErr: "emulation version 1.31 is not between [1.32, 1.35.0]",
},
{
name: "Test when ServerRunOptions is valid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestVersionFlagOptions(t *testing.T) {
func TestVersionFlagOptionsWithMapping(t *testing.T) {
r := testRegistry(t)
utilruntime.Must(r.SetEmulationVersionMapping(testComponent, DefaultKubeComponent,
func(from *version.Version) *version.Version { return from.OffsetMinor(3) }))
func(from *version.Version) *version.Version { return version.MajorMinor(1, from.Minor()+23) }))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was updated because the original test was not written to check the actual values of the mapping, just a placeholder for a mapping exist. So it is actually mapping test 2.8 to kube 2.11, which is not aligned with the kube binary at all.

This change fixes the test to the correct version mapping.

cc @siyuanfoundation @liggitt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is adding 23 to the minor correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping is from test component 2.7 -> kube 1.30 and 2.8 -> kube 1.31 which is where the +23 was derived from specifically for this test.

emuVers := strings.Join(r.unsafeVersionFlagOptions(true), "\n")
expectedEmuVers := "test=2.8..2.8 (default=2.8)"
if emuVers != expectedEmuVers {
Expand Down
2 changes: 1 addition & 1 deletion staging/src/k8s.io/component-base/version/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ const (
// DefaultKubeBinaryVersion is the hard coded k8 binary version based on the latest K8s release.
// It is supposed to be consistent with gitMajor and gitMinor, except for local tests, where gitMajor and gitMinor are "".
// Should update for each minor release!
DefaultKubeBinaryVersion = "1.32"
DefaultKubeBinaryVersion = "1.33"
)
29 changes: 18 additions & 11 deletions staging/src/k8s.io/component-base/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
apimachineryversion "k8s.io/apimachinery/pkg/version"
)

var minimumKubeEmulationVersion *version.Version = version.MajorMinor(1, 31)

type EffectiveVersion interface {
BinaryVersion() *version.Version
EmulationVersion() *version.Version
Expand Down Expand Up @@ -121,8 +123,11 @@ func (m *effectiveVersion) Set(binaryVersion, emulationVersion, minCompatibility

func (m *effectiveVersion) SetEmulationVersion(emulationVersion *version.Version) {
m.emulationVersion.Store(majorMinor(emulationVersion))
// set the default minCompatibilityVersion to be emulationVersion - 1
m.minCompatibilityVersion.Store(majorMinor(emulationVersion.SubtractMinor(1)))
}

// SetMinCompatibilityVersion should be called after SetEmulationVersion
func (m *effectiveVersion) SetMinCompatibilityVersion(minCompatibilityVersion *version.Version) {
m.minCompatibilityVersion.Store(majorMinor(minCompatibilityVersion))
}
Expand All @@ -134,15 +139,15 @@ func (m *effectiveVersion) Validate() []error {
emulationVersion := m.emulationVersion.Load()
minCompatibilityVersion := m.minCompatibilityVersion.Load()

// emulationVersion can only be 1.{binaryMinor-1}...1.{binaryMinor}.
// emulationVersion can only be 1.{binaryMinor-3}...1.{binaryMinor}
maxEmuVer := binaryVersion
minEmuVer := binaryVersion.SubtractMinor(1)
minEmuVer := binaryVersion.SubtractMinor(3)
Jefftree marked this conversation as resolved.
Show resolved Hide resolved
if emulationVersion.GreaterThan(maxEmuVer) || emulationVersion.LessThan(minEmuVer) {
errs = append(errs, fmt.Errorf("emulation version %s is not between [%s, %s]", emulationVersion.String(), minEmuVer.String(), maxEmuVer.String()))
}
// minCompatibilityVersion can only be 1.{binaryMinor-1} for alpha.
maxCompVer := binaryVersion.SubtractMinor(1)
minCompVer := binaryVersion.SubtractMinor(1)
// minCompatibilityVersion can only be 1.{binaryMinor-3} to 1.{binaryMinor}
maxCompVer := emulationVersion
liggitt marked this conversation as resolved.
Show resolved Hide resolved
minCompVer := binaryVersion.SubtractMinor(4)
if minCompatibilityVersion.GreaterThan(maxCompVer) || minCompatibilityVersion.LessThan(minCompVer) {
errs = append(errs, fmt.Errorf("minCompatibilityVersion version %s is not between [%s, %s]", minCompatibilityVersion.String(), minCompVer.String(), maxCompVer.String()))
}
Expand Down Expand Up @@ -187,13 +192,15 @@ func DefaultKubeEffectiveVersion() MutableEffectiveVersion {
return newEffectiveVersion(binaryVersion, false)
}

// ValidateKubeEffectiveVersion validates the EmulationVersion is equal to the binary version at 1.31 for kube components.
// emulationVersion is introduced in 1.31, so it is only allowed to be equal to the binary version at 1.31.
// ValidateKubeEffectiveVersion validates the EmulationVersion is at least 1.31 and MinCompatibilityVersion
// is at least 1.30 for kube components.
func ValidateKubeEffectiveVersion(effectiveVersion EffectiveVersion) error {
binaryVersion := version.MajorMinor(effectiveVersion.BinaryVersion().Major(), effectiveVersion.BinaryVersion().Minor())
if binaryVersion.EqualTo(version.MajorMinor(1, 31)) && !effectiveVersion.EmulationVersion().EqualTo(binaryVersion) {
return fmt.Errorf("emulation version needs to be equal to binary version(%s) in compatibility-version alpha, got %s",
binaryVersion.String(), effectiveVersion.EmulationVersion().String())
if !effectiveVersion.EmulationVersion().AtLeast(minimumKubeEmulationVersion) {
return fmt.Errorf("emulation version needs to be greater or equal to 1.31, got %s", effectiveVersion.EmulationVersion().String())
}
if !effectiveVersion.MinCompatibilityVersion().AtLeast(minimumKubeEmulationVersion.SubtractMinor(1)) {
return fmt.Errorf("minCompatibilityVersion version needs to be greater or equal to 1.30, got %s", effectiveVersion.MinCompatibilityVersion().String())
}

return nil
}
88 changes: 83 additions & 5 deletions staging/src/k8s.io/component-base/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,22 @@ func TestValidate(t *testing.T) {
minCompatibilityVersion: "v1.31.0",
},
{
name: "emulation version two minor lower than binary not ok",
name: "emulation version two minor lower than binary ok",
binaryVersion: "v1.33.2",
emulationVersion: "v1.31.0",
minCompatibilityVersion: "v1.31.0",
expectErrors: false,
},
{
name: "emulation version three minor lower than binary ok",
binaryVersion: "v1.35.0",
emulationVersion: "v1.32.0",
minCompatibilityVersion: "v1.32.0",
},
{
name: "emulation version four minor lower than binary not ok",
binaryVersion: "v1.36.0",
emulationVersion: "v1.32.0",
minCompatibilityVersion: "v1.32.0",
expectErrors: true,
},
Expand All @@ -64,18 +77,25 @@ func TestValidate(t *testing.T) {
expectErrors: true,
},
{
name: "compatibility version same as binary not ok",
name: "compatibility version same as binary ok",
binaryVersion: "v1.32.2",
emulationVersion: "v1.32.0",
minCompatibilityVersion: "v1.32.0",
expectErrors: true,
expectErrors: false,
},
{
name: "compatibility version two minor lower than binary not ok",
name: "compatibility version two minor lower than binary ok",
Jefftree marked this conversation as resolved.
Show resolved Hide resolved
binaryVersion: "v1.32.2",
emulationVersion: "v1.32.0",
minCompatibilityVersion: "v1.30.0",
expectErrors: true,
expectErrors: false,
},
{
name: "compatibility version three minor lower than binary ok",
binaryVersion: "v1.34.2",
emulationVersion: "v1.33.0",
minCompatibilityVersion: "v1.31.0",
expectErrors: false,
},
{
name: "compatibility version one minor higher than binary not ok",
Expand All @@ -84,6 +104,13 @@ func TestValidate(t *testing.T) {
minCompatibilityVersion: "v1.33.0",
expectErrors: true,
},
{
name: "emulation version lower than compatibility version not ok",
binaryVersion: "v1.34.2",
emulationVersion: "v1.32.0",
minCompatibilityVersion: "v1.33.0",
expectErrors: true,
},
}

for _, test := range tests {
Expand All @@ -105,3 +132,54 @@ func TestValidate(t *testing.T) {
})
}
}

func TestValidateKubeEffectiveVersion(t *testing.T) {
tests := []struct {
name string
emulationVersion string
minCompatibilityVersion string
expectErr bool
}{
{
name: "valid versions",
emulationVersion: "v1.31.0",
minCompatibilityVersion: "v1.31.0",
expectErr: false,
},
{
name: "emulationVersion too low",
emulationVersion: "v1.30.0",
minCompatibilityVersion: "v1.31.0",
expectErr: true,
},
{
name: "minCompatibilityVersion too low",
emulationVersion: "v1.31.0",
minCompatibilityVersion: "v1.29.0",
expectErr: true,
},
{
name: "both versions too low",
emulationVersion: "v1.30.0",
minCompatibilityVersion: "v1.30.0",
expectErr: true,
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

effective := NewEffectiveVersion("1.32")
effective.SetEmulationVersion(version.MustParseGeneric(test.emulationVersion))
effective.SetMinCompatibilityVersion(version.MustParseGeneric(test.minCompatibilityVersion))

err := ValidateKubeEffectiveVersion(effective)
if test.expectErr && err == nil {
t.Error("expected error, but got nil")
}
if !test.expectErr && err != nil {
t.Errorf("unexpected error: %v", err)
}
})
}
}
14 changes: 0 additions & 14 deletions test/integration/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2975,20 +2975,6 @@ func TestEmulatedStorageVersion(t *testing.T) {
expectedStorageVersion schema.GroupVersion
}
cases := []testCase{
{
Jefftree marked this conversation as resolved.
Show resolved Hide resolved
name: "vap first ga release",
emulatedVersion: "1.30",
gvr: schema.GroupVersionResource{
Group: "admissionregistration.k8s.io",
Version: "v1",
Resource: "validatingadmissionpolicies",
},
object: validVap,
expectedStorageVersion: schema.GroupVersion{
Group: "admissionregistration.k8s.io",
Version: "v1beta1",
},
},
{
name: "vap after ga release",
emulatedVersion: "1.31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ resources:
endpoint: unix:///@encrypt-all-kms-provider.sock
`

// KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE allows for APIs pending removal to not block tests
t.Setenv("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE", "true")

t.Run("encrypt all resources", func(t *testing.T) {
_ = mock.NewBase64Plugin(t, "@encrypt-all-kms-provider.sock")
// To ensure we are checking all REST resources
Expand Down
80 changes: 66 additions & 14 deletions test/integration/etcd/data.go
Copy link
Member

@liggitt liggitt Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's find a way to retain coverage for this specific test for types which can only be served under emulation, while minimizing the diff to etcd/data. Something like this:

diff --git a/test/integration/etcd/data.go b/test/integration/etcd/data.go
index d2ef43b7c9c..93b20c025d9 100644
--- a/test/integration/etcd/data.go
+++ b/test/integration/etcd/data.go
@@ -29,7 +29,7 @@ import (
 // It is exported so that it can be reused across multiple tests.
 // It returns a new map on every invocation to prevent different tests from mutating shared state.
 func GetEtcdStorageData() map[schema.GroupVersionResource]StorageData {
-	return GetEtcdStorageDataForNamespace("etcdstoragepathtestnamespace")
+	return GetEtcdStorageDataForNamespaceServedAt("etcdstoragepathtestnamespace", utilversion.DefaultKubeEffectiveVersion().BinaryVersion().String(), true)
 }
 
 // GetEtcdStorageDataForNamespace returns etcd data for all persisted objects.
@@ -37,6 +37,10 @@ func GetEtcdStorageData() map[schema.GroupVersionResource]StorageData {
 // It returns a new map on every invocation to prevent different tests from mutating shared state.
 // Namespaced objects keys are computed for the specified namespace.
 func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionResource]StorageData {
+	return GetEtcdStorageDataForNamespaceServedAt(namespace, utilversion.DefaultKubeEffectiveVersion().BinaryVersion().String(), true)
+}
+
+func GetEtcdStorageDataForNamespaceServedAt(namespace string, emulationVersion string, includeAlpha bool) map[schema.GroupVersionResource]StorageData {
 	image := image.GetE2EImage(image.BusyBox)
 	etcdStorageData := map[schema.GroupVersionResource]StorageData{
 		// k8s.io/kubernetes/pkg/api/v1
@@ -481,6 +485,23 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
 		ExpectedEtcdPath: "/registry/csidrivers/csid2",
 	}
 
+	// ... delete stuff no longer served or not yet added at at emulatedVersion
+	// TODO: derive this programtically from gvk --> instance --> APILifecycle info
+	switch emulatedVersion {
+	case "1.33":
+		// delete flowcontrol
+	case "1.32":
+		// delete flowcontrol
+		// delete mutatingadmission
+	case "1.31":
+		// delete mutatingadmission
+	default:
+		error
+	}
+	if !includeAlpha {
+		// drop all alphas from etcdStorageData
+	}
+
 	return etcdStorageData
 }
 
diff --git a/test/integration/etcd/etcd_storage_path_test.go b/test/integration/etcd/etcd_storage_path_test.go
index bedc000856b..e909e4ee61b 100644
--- a/test/integration/etcd/etcd_storage_path_test.go
+++ b/test/integration/etcd/etcd_storage_path_test.go
@@ -75,13 +75,19 @@ var allowMissingTestdataFixtures = map[schema.GroupVersionKind]bool{
 // It will also fail when a type gets moved to a different location. Be very careful in this situation because
 // it essentially means that you will be break old clusters unless you create some migration path for the old data.
 func TestEtcdStoragePath(t *testing.T) {
+	testEtcdStoragePathAtVersion(t, utilversion.DefaultKubeEffectiveVersion().BinaryVersion().String(), true)
+	testEtcdStoragePathAtVersion(t, utilversion.DefaultKubeEffectiveVersion().BinaryVersion().SubtractMinor(1).String(), false)
+	testEtcdStoragePathAtVersion(t, utilversion.DefaultKubeEffectiveVersion().BinaryVersion().SubtractMinor(2).String(), false)
+}
+
+func testEtcdStoragePathAtVersion(t *testing.T, emulateVersion string, includeAlpha bool) {
 	// KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE allows for APIs pending removal to not block tests
 	t.Setenv("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE", "true")
 
 	featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, "AllAlpha", true)
 	featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, "AllBeta", true)
 
-	apiServer := StartRealAPIServerOrDie(t)
+	apiServer := StartRealAPIServerOrDie(t, withEmulationVersion(emulateVersion))
 	defer apiServer.Cleanup()
 	defer dumpEtcdKVOnFailure(t, apiServer.KV)
 
@@ -91,7 +97,7 @@ func TestEtcdStoragePath(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	etcdStorageData := GetEtcdStorageData()
+	etcdStorageData := GetEtcdStorageDataForNamespaceServedAt("etcdstoragepathtestnamespace", emulateVersion, includeAlpha)
 
 	kindSeen := sets.NewString()
 	pathSeen := map[string][]schema.GroupVersionResource{}
diff --git a/test/integration/etcd/server.go b/test/integration/etcd/server.go
index 03911859aaf..08df976cbe8 100644
--- a/test/integration/etcd/server.go
+++ b/test/integration/etcd/server.go
@@ -62,6 +62,19 @@ AwEHoUQDQgAEH6cuzP8XuD5wal6wf9M6xDljTOPLX2i8uIp/C/ASqiIGUeeKQtX0
 /IR3qCXyThP/dbCiHrF3v1cuhBOHY8CLVg==
 -----END EC PRIVATE KEY-----`
 
+func withEmulationVersion(emulationVersion string) func(*options.ServerRunOptions) {
+	return func(*options.ServerRunOptions) {
+		featureGate := feature.DefaultMutableFeatureGate
+		featureGate.AddMetrics()
+
+		effectiveVersion := utilversion.DefaultKubeEffectiveVersion()
+		effectiveVersion.SetEmulationVersion(featureGate.EmulationVersion())
+		featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, featureGate, effectiveVersion.EmulationVersion())
+		featuregate.DefaultComponentGlobalsRegistry.Reset()
+		utilruntime.Must(featuregate.DefaultComponentGlobalsRegistry.Register(featuregate.DefaultKubeComponent, effectiveVersion, featureGate))
+	}
+}
+
 // StartRealAPIServerOrDie starts an API server that is appropriate for use in tests that require one of every resource
 func StartRealAPIServerOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOptions)) *APIServer {
 	tCtx := ktesting.Init(t)

Copy link
Member

@liggitt liggitt Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any API objects which change their storage version depending on emulation version will need to calculate their expected GVK from the incoming emulationVersion as well, for example:

			ExpectedGVK:      (func() *schema.GroupVersionKind {
				switch emulationVersion {
				case "1.31":
					return gvkP("...."),
				case "1.32":
					return gvkP("...."),
				default:
					return gvkP("...."),
				}
			})(),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any API objects which change their storage version depending on emulation version will need to calculate their expected GVK from the incoming emulationVersion as well, for example:

			ExpectedGVK:      (func() *schema.GroupVersionKind {
				switch emulationVersion {
				case "1.31":
					return gvkP("...."),
				case "1.32":
					return gvkP("...."),
				default:
					return gvkP("...."),
				}
			})(),

ack, we do not have any instances of this at the moment and it'll probably occur on our next GA API promotion.

I've addressed the other diffs.

Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,54 @@ limitations under the License.
package etcd

import (
"strings"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/test/integration/fixtures"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
utilversion "k8s.io/component-base/version"

"k8s.io/kubernetes/test/utils/image"
)

// GetEtcdStorageData returns etcd data for all persisted objects.
// GetSupportedEmulatedVersions provides the list of supported emulated versions in the etcd data.
// Tests aiming for full coverage of versions should test fixtures of all supported versions.
func GetSupportedEmulatedVersions() []string {
return []string{
utilversion.DefaultKubeEffectiveVersion().BinaryVersion().SubtractMinor(2).String(),
utilversion.DefaultKubeEffectiveVersion().BinaryVersion().SubtractMinor(1).String(),
utilversion.DefaultKubeEffectiveVersion().BinaryVersion().String(),
}
}

// GetEtcdStorageData returns etcd data for all persisted objects at the latest release version.
// It is exported so that it can be reused across multiple tests.
// It returns a new map on every invocation to prevent different tests from mutating shared state.
func GetEtcdStorageData() map[schema.GroupVersionResource]StorageData {
return GetEtcdStorageDataForNamespace("etcdstoragepathtestnamespace")
return GetEtcdStorageDataServedAt(utilversion.DefaultKubeBinaryVersion, false)
}

// GetEtcdStorageDataForNamespace returns etcd data for all persisted objects.
// GetEtcdStorageDataServedAt returns etcd data for all persisted objects at a particular release version.
// It is exported so that it can be reused across multiple tests.
// It returns a new map on every invocation to prevent different tests from mutating shared state.
func GetEtcdStorageDataServedAt(version string, removeAlphas bool) map[schema.GroupVersionResource]StorageData {
return GetEtcdStorageDataForNamespaceServedAt("etcdstoragepathtestnamespace", version, removeAlphas)
}

// GetEtcdStorageDataForNamespace returns etcd data for all persisted objects at the latest release version.
// It is exported so that it can be reused across multiple tests.
// It returns a new map on every invocation to prevent different tests from mutating shared state.
// Namespaced objects keys are computed for the specified namespace.
func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionResource]StorageData {
return GetEtcdStorageDataForNamespaceServedAt(namespace, utilversion.DefaultKubeBinaryVersion, false)
}

// GetEtcdStorageDataForNamespaceServedAt returns etcd data for all persisted objects at a particular release version.
// It is exported so that it can be reused across multiple tests.
// It returns a new map on every invocation to prevent different tests from mutating shared state.
// Namespaced objects keys are computed for the specified namespace.
func GetEtcdStorageDataForNamespaceServedAt(namespace string, version string, removeAlphas bool) map[schema.GroupVersionResource]StorageData {
image := image.GetE2EImage(image.BusyBox)
etcdStorageData := map[schema.GroupVersionResource]StorageData{
// k8s.io/kubernetes/pkg/api/v1
Expand Down Expand Up @@ -465,22 +493,46 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
},
// --

}
// k8s.io/kubernetes/pkg/apis/storage/v1
gvr("storage.k8s.io", "v1", "csinodes"): {
Stub: `{"metadata": {"name": "csini2"}, "spec": {"drivers": [{"name": "test-driver", "nodeID": "localhost", "topologyKeys": ["company.com/zone1", "company.com/zone2"]}]}}`,
ExpectedEtcdPath: "/registry/csinodes/csini2",
},
// --

// add csinodes
// k8s.io/kubernetes/pkg/apis/storage/v1
etcdStorageData[gvr("storage.k8s.io", "v1", "csinodes")] = StorageData{
Stub: `{"metadata": {"name": "csini2"}, "spec": {"drivers": [{"name": "test-driver", "nodeID": "localhost", "topologyKeys": ["company.com/zone1", "company.com/zone2"]}]}}`,
ExpectedEtcdPath: "/registry/csinodes/csini2",
// k8s.io/kubernetes/pkg/apis/storage/v1
gvr("storage.k8s.io", "v1", "csidrivers"): {
Stub: `{"metadata": {"name": "csid2"}, "spec": {"attachRequired": true, "podInfoOnMount": true}}`,
ExpectedEtcdPath: "/registry/csidrivers/csid2",
},
// --
}

// add csidrivers
// k8s.io/kubernetes/pkg/apis/storage/v1
etcdStorageData[gvr("storage.k8s.io", "v1", "csidrivers")] = StorageData{
Stub: `{"metadata": {"name": "csid2"}, "spec": {"attachRequired": true, "podInfoOnMount": true}}`,
ExpectedEtcdPath: "/registry/csidrivers/csid2",
// Delete types no longer served or not yet added at a particular emulated version.
// When adding a brand new type non-alpha type in the latest release, please ensure that
// it is removed in previous emulated versions otherwise emulated version tests will fail.
// TODO: derive this programatically from gvk --> instance --> APILifecycle info
switch version {
case "1.33":
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "flowschemas"))
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "prioritylevelconfigurations"))
case "1.32":
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "flowschemas"))
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "prioritylevelconfigurations"))
case "1.31":
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "deviceclasses"))
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "resourceclaims"))
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "resourceclaimtemplates"))
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "resourceslices"))
}

if removeAlphas {
for key := range etcdStorageData {
if strings.Contains(key.Version, "alpha") {
delete(etcdStorageData, key)
}
}
}
return etcdStorageData
}

Expand Down
Loading