CSIStorageCapacity: use v1 as storage version

This can be done because downgrades are only supported down to 1.24 and that
release supports v1.
This commit is contained in:
Patrick Ohly 2022-04-08 17:24:26 +02:00
parent 4569e646ef
commit 2e8fa3ee6b
3 changed files with 15 additions and 8 deletions

View File

@ -72,9 +72,9 @@ var GVRToStorageVersionHash = map[string]string{
"storage.k8s.io/v1/csidrivers": "hL6j/rwBV5w=", "storage.k8s.io/v1/csidrivers": "hL6j/rwBV5w=",
"storage.k8s.io/v1/csinodes": "Pe62DkZtjuo=", "storage.k8s.io/v1/csinodes": "Pe62DkZtjuo=",
"storage.k8s.io/v1/storageclasses": "K+m6uJwbjGY=", "storage.k8s.io/v1/storageclasses": "K+m6uJwbjGY=",
"storage.k8s.io/v1/csistoragecapacities": "4as6MA/kOg0=", "storage.k8s.io/v1/csistoragecapacities": "xeVl+2Ly1kE=",
"storage.k8s.io/v1/volumeattachments": "tJx/ezt6UDU=", "storage.k8s.io/v1/volumeattachments": "tJx/ezt6UDU=",
"storage.k8s.io/v1beta1/csistoragecapacities": "4as6MA/kOg0=", "storage.k8s.io/v1beta1/csistoragecapacities": "xeVl+2Ly1kE=",
"apps/v1/controllerrevisions": "85nkx63pcBU=", "apps/v1/controllerrevisions": "85nkx63pcBU=",
"apps/v1/daemonsets": "dd7pWHUlMKQ=", "apps/v1/daemonsets": "dd7pWHUlMKQ=",
"apps/v1/deployments": "8aSe+NMegvE=", "apps/v1/deployments": "8aSe+NMegvE=",

View File

@ -33,7 +33,6 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/networking" "k8s.io/kubernetes/pkg/apis/networking"
"k8s.io/kubernetes/pkg/apis/policy" "k8s.io/kubernetes/pkg/apis/policy"
apisstorage "k8s.io/kubernetes/pkg/apis/storage"
) )
// SpecialDefaultResourcePrefixes are prefixes compiled into Kubernetes. // SpecialDefaultResourcePrefixes are prefixes compiled into Kubernetes.
@ -61,9 +60,17 @@ func DefaultWatchCacheSizes() map[schema.GroupResource]int {
func NewStorageFactoryConfig() *StorageFactoryConfig { func NewStorageFactoryConfig() *StorageFactoryConfig {
resources := []schema.GroupVersionResource{ resources := []schema.GroupVersionResource{
// TODO (https://github.com/kubernetes/kubernetes/issues/108451): remove the override in // If a resource has to be stored in a version that is not the
// 1.25. // latest, then it can be listed here. Usually this is the case
apisstorage.Resource("csistoragecapacities").WithVersion("v1beta1"), // when a new version for a resource gets introduced and a
// downgrade to an older apiserver that doesn't know the new
// version still needs to be supported for one release.
//
// Example from Kubernetes 1.24 where csistoragecapacities had just
// graduated to GA:
//
// TODO (https://github.com/kubernetes/kubernetes/issues/108451): remove the override in 1.25.
// apisstorage.Resource("csistoragecapacities").WithVersion("v1beta1"),
} }
return &StorageFactoryConfig{ return &StorageFactoryConfig{

View File

@ -257,7 +257,7 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
gvr("storage.k8s.io", "v1alpha1", "csistoragecapacities"): { gvr("storage.k8s.io", "v1alpha1", "csistoragecapacities"): {
Stub: `{"metadata": {"name": "csc-12345-1"}, "storageClassName": "sc1"}`, Stub: `{"metadata": {"name": "csc-12345-1"}, "storageClassName": "sc1"}`,
ExpectedEtcdPath: "/registry/csistoragecapacities/" + namespace + "/csc-12345-1", ExpectedEtcdPath: "/registry/csistoragecapacities/" + namespace + "/csc-12345-1",
ExpectedGVK: gvkP("storage.k8s.io", "v1beta1", "CSIStorageCapacity"), ExpectedGVK: gvkP("storage.k8s.io", "v1", "CSIStorageCapacity"),
}, },
// -- // --
@ -318,6 +318,7 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
gvr("storage.k8s.io", "v1beta1", "csistoragecapacities"): { gvr("storage.k8s.io", "v1beta1", "csistoragecapacities"): {
Stub: `{"metadata": {"name": "csc-12345-2"}, "storageClassName": "sc1"}`, Stub: `{"metadata": {"name": "csc-12345-2"}, "storageClassName": "sc1"}`,
ExpectedEtcdPath: "/registry/csistoragecapacities/" + namespace + "/csc-12345-2", ExpectedEtcdPath: "/registry/csistoragecapacities/" + namespace + "/csc-12345-2",
ExpectedGVK: gvkP("storage.k8s.io", "v1", "CSIStorageCapacity"),
}, },
// -- // --
@ -329,7 +330,6 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
gvr("storage.k8s.io", "v1", "csistoragecapacities"): { gvr("storage.k8s.io", "v1", "csistoragecapacities"): {
Stub: `{"metadata": {"name": "csc-12345-3"}, "storageClassName": "sc1"}`, Stub: `{"metadata": {"name": "csc-12345-3"}, "storageClassName": "sc1"}`,
ExpectedEtcdPath: "/registry/csistoragecapacities/" + namespace + "/csc-12345-3", ExpectedEtcdPath: "/registry/csistoragecapacities/" + namespace + "/csc-12345-3",
ExpectedGVK: gvkP("storage.k8s.io", "v1beta1", "CSIStorageCapacity"),
}, },
// -- // --