From 1a753659cfc973e900620bf1443178b6cdda27e0 Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 24 Apr 2018 10:16:59 -0400 Subject: [PATCH] core v1 API requires autoscaling/v1 to serve the Scale endpoint --- hack/test-update-storage-objects.sh | 6 +++--- .../apiserver/pkg/server/resourceconfig/helpers.go | 4 ++-- .../apiserver/pkg/server/storage/resource_config.go | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/hack/test-update-storage-objects.sh b/hack/test-update-storage-objects.sh index aca9c48e2aa..1540329726a 100755 --- a/hack/test-update-storage-objects.sh +++ b/hack/test-update-storage-objects.sh @@ -120,7 +120,7 @@ KUBE_NEW_STORAGE_VERSIONS="storage.k8s.io/v1" # but KUBE_OLD_API_VERSION is the latest (storage) version. # Additionally use KUBE_STORAGE_MEDIA_TYPE_JSON for storage encoding. ####################################################### -KUBE_API_VERSIONS="v1,${KUBE_OLD_API_VERSION},${KUBE_NEW_API_VERSION}" +KUBE_API_VERSIONS="v1,autoscaling/v1,${KUBE_OLD_API_VERSION},${KUBE_NEW_API_VERSION}" RUNTIME_CONFIG="api/all=false,api/v1=true,${KUBE_OLD_API_VERSION}=true,${KUBE_NEW_API_VERSION}=true" startApiServer ${KUBE_OLD_STORAGE_VERSIONS} ${KUBE_STORAGE_MEDIA_TYPE_JSON} @@ -155,7 +155,7 @@ killApiServer # Still use KUBE_STORAGE_MEDIA_TYPE_JSON for storage encoding. ####################################################### -KUBE_API_VERSIONS="v1,${KUBE_NEW_API_VERSION},${KUBE_OLD_API_VERSION}" +KUBE_API_VERSIONS="v1,autoscaling/v1,${KUBE_NEW_API_VERSION},${KUBE_OLD_API_VERSION}" RUNTIME_CONFIG="api/all=false,api/v1=true,${KUBE_OLD_API_VERSION}=true,${KUBE_NEW_API_VERSION}=true" startApiServer ${KUBE_NEW_STORAGE_VERSIONS} ${KUBE_STORAGE_MEDIA_TYPE_JSON} @@ -186,7 +186,7 @@ killApiServer # However, change storage encoding to KUBE_STORAGE_MEDIA_TYPE_PROTOBUF. ####################################################### -KUBE_API_VERSIONS="v1,${KUBE_NEW_API_VERSION}" +KUBE_API_VERSIONS="v1,autoscaling/v1,${KUBE_NEW_API_VERSION}" RUNTIME_CONFIG="api/all=false,api/v1=true,${KUBE_NEW_API_VERSION}=true" # This seems to reduce flakiness. diff --git a/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers.go b/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers.go index 3ac79b74a60..ee0f08e5f79 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers.go +++ b/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers.go @@ -78,9 +78,9 @@ func MergeAPIResourceConfigs( if ok { if allAPIFlagValue == "false" { // Disable all group versions. - resourceConfig.DisableVersions(registry.RegisteredGroupVersions()...) + resourceConfig.DisableAll() } else if allAPIFlagValue == "true" { - resourceConfig.EnableVersions(registry.RegisteredGroupVersions()...) + resourceConfig.EnableAll() } } diff --git a/staging/src/k8s.io/apiserver/pkg/server/storage/resource_config.go b/staging/src/k8s.io/apiserver/pkg/server/storage/resource_config.go index 0a44706056a..d16be4279a3 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/storage/resource_config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/storage/resource_config.go @@ -36,6 +36,18 @@ func NewResourceConfig() *ResourceConfig { return &ResourceConfig{GroupVersionConfigs: map[schema.GroupVersion]bool{}} } +func (o *ResourceConfig) DisableAll() { + for k := range o.GroupVersionConfigs { + o.GroupVersionConfigs[k] = false + } +} + +func (o *ResourceConfig) EnableAll() { + for k := range o.GroupVersionConfigs { + o.GroupVersionConfigs[k] = true + } +} + // DisableVersions disables the versions entirely. func (o *ResourceConfig) DisableVersions(versions ...schema.GroupVersion) { for _, version := range versions {