Merge pull request #110904 from 249043822/storageversion

Computation of the StorageVersionHash use overridden storage versions in unit test
This commit is contained in:
Kubernetes Prow Robot 2022-07-07 19:11:58 -07:00 committed by GitHub
commit 9509211fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 19 deletions

View File

@ -57,12 +57,10 @@ import (
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
kubeversion "k8s.io/component-base/version" kubeversion "k8s.io/component-base/version"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/batch"
flowcontrolv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2" flowcontrolv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
"k8s.io/kubernetes/pkg/apis/networking"
apisstorage "k8s.io/kubernetes/pkg/apis/storage"
"k8s.io/kubernetes/pkg/controlplane/reconcilers" "k8s.io/kubernetes/pkg/controlplane/reconcilers"
"k8s.io/kubernetes/pkg/controlplane/storageversionhashdata" "k8s.io/kubernetes/pkg/controlplane/storageversionhashdata"
"k8s.io/kubernetes/pkg/kubeapiserver"
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" kubeletclient "k8s.io/kubernetes/pkg/kubelet/client"
certificatesrest "k8s.io/kubernetes/pkg/registry/certificates/rest" certificatesrest "k8s.io/kubernetes/pkg/registry/certificates/rest"
corerest "k8s.io/kubernetes/pkg/registry/core/rest" corerest "k8s.io/kubernetes/pkg/registry/core/rest"
@ -87,17 +85,9 @@ func setUp(t *testing.T) (*etcd3testing.EtcdTestServer, Config, *assert.Assertio
}, },
} }
resourceEncoding := serverstorage.NewDefaultResourceEncodingConfig(legacyscheme.Scheme) storageFactoryConfig := kubeapiserver.NewStorageFactoryConfig()
// This configures the testing apiserver the same way the real apiserver is resourceEncoding := resourceconfig.MergeResourceEncodingConfigs(storageFactoryConfig.DefaultResourceEncoding, storageFactoryConfig.ResourceEncodingOverrides)
// configured. The storage versions of these resources are different storageFactory := serverstorage.NewDefaultStorageFactory(*storageConfig, "application/vnd.kubernetes.protobuf", storageFactoryConfig.Serializer, resourceEncoding, DefaultAPIResourceConfigSource(), nil)
// from the storage versions of other resources in their group.
resourceEncodingOverrides := []schema.GroupVersionResource{
batch.Resource("cronjobs").WithVersion("v1beta1"),
apisstorage.Resource("volumeattachments").WithVersion("v1beta1"),
networking.Resource("ingresses").WithVersion("v1beta1"),
}
resourceEncoding = resourceconfig.MergeResourceEncodingConfigs(resourceEncoding, resourceEncodingOverrides)
storageFactory := serverstorage.NewDefaultStorageFactory(*storageConfig, "application/vnd.kubernetes.protobuf", legacyscheme.Codecs, resourceEncoding, DefaultAPIResourceConfigSource(), nil)
etcdOptions := options.NewEtcdOptions(storageConfig) etcdOptions := options.NewEtcdOptions(storageConfig)
// unit tests don't need watch cache and it leaks lots of goroutines with etcd testing functions during unit tests // unit tests don't need watch cache and it leaks lots of goroutines with etcd testing functions during unit tests

View File

@ -55,12 +55,12 @@ var GVRToStorageVersionHash = map[string]string{
"autoscaling/v2/horizontalpodautoscalers": "oQlkt7f5j/A=", "autoscaling/v2/horizontalpodautoscalers": "oQlkt7f5j/A=",
"autoscaling/v2beta2/horizontalpodautoscalers": "oQlkt7f5j/A=", "autoscaling/v2beta2/horizontalpodautoscalers": "oQlkt7f5j/A=",
"batch/v1/jobs": "mudhfqk/qZY=", "batch/v1/jobs": "mudhfqk/qZY=",
"batch/v1/cronjobs": "h/JlFAZkyyY=", "batch/v1/cronjobs": "sd5LIXh4Fjs=",
"certificates.k8s.io/v1/certificatesigningrequests": "95fRKMXA+00=", "certificates.k8s.io/v1/certificatesigningrequests": "95fRKMXA+00=",
"coordination.k8s.io/v1/leases": "gqkMMb/YqFM=", "coordination.k8s.io/v1/leases": "gqkMMb/YqFM=",
"discovery.k8s.io/v1/endpointslices": "Nx3SIv6I0mE=", "discovery.k8s.io/v1/endpointslices": "Nx3SIv6I0mE=",
"networking.k8s.io/v1/networkpolicies": "YpfwF18m1G8=", "networking.k8s.io/v1/networkpolicies": "YpfwF18m1G8=",
"networking.k8s.io/v1/ingresses": "ZOAfGflaKd0=", "networking.k8s.io/v1/ingresses": "39NQlfNR+bo=",
"networking.k8s.io/v1/ingressclasses": "l/iqIbDgFyQ=", "networking.k8s.io/v1/ingressclasses": "l/iqIbDgFyQ=",
"node.k8s.io/v1/runtimeclasses": "WQTu1GL3T2Q=", "node.k8s.io/v1/runtimeclasses": "WQTu1GL3T2Q=",
"policy/v1/poddisruptionbudgets": "6BGBu0kpHtk=", "policy/v1/poddisruptionbudgets": "6BGBu0kpHtk=",
@ -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": "xeVl+2Ly1kE=", "storage.k8s.io/v1/csistoragecapacities": "4as6MA/kOg0=",
"storage.k8s.io/v1/volumeattachments": "vQAqD28V4AY=", "storage.k8s.io/v1/volumeattachments": "tJx/ezt6UDU=",
"storage.k8s.io/v1beta1/csistoragecapacities": "xeVl+2Ly1kE=", "storage.k8s.io/v1beta1/csistoragecapacities": "4as6MA/kOg0=",
"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=",