From 49608469c41bbbc53289f56766012c4c980e3665 Mon Sep 17 00:00:00 2001 From: David Eads Date: Mon, 14 Jan 2019 13:06:56 -0500 Subject: [PATCH] remove oapi --- .../configprocessing/requestinforesolver.go | 4 +- .../openshiftapiserver/legacy.go | 136 ---------- .../openshiftapiserver/openshift_apiserver.go | 232 ++++-------------- test/integration/etcd_storage_path_test.go | 7 - 4 files changed, 54 insertions(+), 325 deletions(-) delete mode 100644 pkg/cmd/openshift-apiserver/openshiftapiserver/legacy.go diff --git a/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing/requestinforesolver.go b/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing/requestinforesolver.go index 1340c0ab8b41..108f22be445e 100644 --- a/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing/requestinforesolver.go +++ b/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing/requestinforesolver.go @@ -13,8 +13,8 @@ var LegacyAPIGroupPrefixes = sets.NewString(genericapiserver.DefaultLegacyAPIPre func OpenshiftRequestInfoResolver() apirequest.RequestInfoResolver { // Default API request info factory requestInfoFactory := &apirequest.RequestInfoFactory{ - APIPrefixes: sets.NewString("api", "osapi", "oapi", "apis"), - GrouplessAPIPrefixes: sets.NewString("api", "osapi", "oapi"), + APIPrefixes: sets.NewString("api", "apis"), + GrouplessAPIPrefixes: sets.NewString("api"), } personalSARRequestInfoResolver := oauthorizer.NewPersonalSARRequestInfoResolver(requestInfoFactory) projectRequestInfoResolver := oauthorizer.NewProjectRequestInfoResolver(personalSARRequestInfoResolver) diff --git a/pkg/cmd/openshift-apiserver/openshiftapiserver/legacy.go b/pkg/cmd/openshift-apiserver/openshiftapiserver/legacy.go deleted file mode 100644 index 75f8b485da79..000000000000 --- a/pkg/cmd/openshift-apiserver/openshiftapiserver/legacy.go +++ /dev/null @@ -1,136 +0,0 @@ -package openshiftapiserver - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apiserver/pkg/registry/rest" - - "github.com/openshift/origin/pkg/apps/apiserver/registry/deployconfig" - deploymentconfigetcd "github.com/openshift/origin/pkg/apps/apiserver/registry/deployconfig/etcd" - buildetcd "github.com/openshift/origin/pkg/build/apiserver/registry/build/etcd" - buildconfig "github.com/openshift/origin/pkg/build/apiserver/registry/buildconfig" - buildconfigetcd "github.com/openshift/origin/pkg/build/apiserver/registry/buildconfig/etcd" - imagestreametcd "github.com/openshift/origin/pkg/image/apiserver/registry/imagestream/etcd" - routeregistry "github.com/openshift/origin/pkg/route/apiserver/registry/route" - routeetcd "github.com/openshift/origin/pkg/route/apiserver/registry/route/etcd" -) - -var ( - // originLegacyResources lists all Origin resources that are locked for the legacy v1 - // Origin API. This list should not grow. - originLegacyResources = sets.NewString( - "appliedClusterResourceQuotas", - "buildConfigs", - "builds", - "clusterNetworks", - "clusterResourceQuotas", - "clusterRoleBindings", - "clusterRoles", - "deploymentConfigRollbacks", - "deploymentConfigs", - "egressNetworkPolicies", - "groups", - "hostSubnets", - "identities", - "imageStreamImages", - "imageStreamImports", - "imageStreamMappings", - "imageStreamTags", - "imageStreams", - "images", - "imagesignatures", - "localResourceAccessReviews", - "localSubjectAccessReviews", - "netNamespaces", - "oAuthAccessTokens", - "oAuthAuthorizeTokens", - "oAuthClientAuthorizations", - "oAuthClients", - "podSecurityPolicyReviews", - "podSecurityPolicySelfSubjectReviews", - "podSecurityPolicySubjectReviews", - "policies", - "policyBindings", - "processedTemplates", - "projectRequests", - "projects", - "resourceAccessReviews", - "roleBindingRestrictions", - "roleBindings", - "roles", - "routes", - "selfSubjectRulesReviews", - "subjectAccessReviews", - "subjectRulesReviews", - "templates", - "userIdentityMappings", - "users", - ) - - // originLegacySubresources lists all Origin sub-resources that are locked for the - // legacy v1 Origin API. This list should not grow. - originLegacySubresources = sets.NewString( - "clusterResourceQuotas/status", - "processedTemplates", - "imageStreams/status", - "imageStreams/secrets", - "generateDeploymentConfigs", - "deploymentConfigs/log", - "deploymentConfigs/instantiate", - "deploymentConfigs/scale", - "deploymentConfigs/status", - "deploymentConfigs/rollback", - "routes/status", - "builds/clone", - "builds/log", - "builds/details", - "buildConfigs/webhooks", - "buildConfigs/instantiate", - "buildConfigs/instantiatebinary", - ) -) - -// LegacyStorage returns a storage for locked legacy types. -func LegacyStorage(storage map[schema.GroupVersion]map[string]rest.Storage) map[string]rest.Storage { - legacyStorage := map[string]rest.Storage{} - for _, gvStorage := range storage { - for resource, s := range gvStorage { - if originLegacyResources.Has(resource) || originLegacySubresources.Has(resource) { - // We want *some* our legacy resources to orphan by default instead of garbage collecting. - // Kube only did this for a select few resources which were controller managed and established links - // via a workload controller. In openshift, these will all conform to registry.Store so we - // can actually wrap the "normal" storage here. - switch storage := s.(type) { - case *buildetcd.REST: - legacyStorage[resource] = &buildetcd.LegacyREST{REST: storage} - - case *buildconfigetcd.REST: - store := *storage.Store - store.DeleteStrategy = buildconfig.LegacyStrategy - store.CreateStrategy = buildconfig.LegacyStrategy - legacyStorage[resource] = &buildconfigetcd.LegacyREST{REST: &buildconfigetcd.REST{Store: &store}} - - case *deploymentconfigetcd.REST: - store := *storage.Store - store.CreateStrategy = deployconfig.LegacyStrategy - store.DeleteStrategy = deployconfig.LegacyStrategy - legacyStorage[resource] = &deploymentconfigetcd.LegacyREST{REST: &deploymentconfigetcd.REST{Store: &store}} - - case *imagestreametcd.REST: - legacyStorage[resource] = &imagestreametcd.LegacyREST{REST: storage} - case *imagestreametcd.LayersREST: - delete(legacyStorage, resource) - - case *routeetcd.REST: - store := *storage.Store - store.Decorator = routeregistry.DecorateLegacyRouteWithEmptyDestinationCACertificates - legacyStorage[resource] = &routeetcd.LegacyREST{REST: &routeetcd.REST{Store: &store}} - - default: - legacyStorage[resource] = s - } - } - } - } - return legacyStorage -} diff --git a/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go b/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go index a2255716c2db..ca077ce40efd 100644 --- a/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go +++ b/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go @@ -4,20 +4,16 @@ import ( "encoding/json" "fmt" "net/http" - "strings" "time" restful "github.com/emicklei/go-restful" "github.com/golang/glog" - "k8s.io/api/core/v1" kapierror "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" utilerrors "k8s.io/apimachinery/pkg/util/errors" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apiserver/pkg/registry/rest" genericapiserver "k8s.io/apiserver/pkg/server" genericmux "k8s.io/apiserver/pkg/server/mux" kubeinformers "k8s.io/client-go/informers" @@ -30,7 +26,6 @@ import ( rbacregistryvalidation "k8s.io/kubernetes/pkg/registry/rbac/validation" rbacauthorizer "k8s.io/kubernetes/plugin/pkg/auth/authorizer/rbac" - oappsapiv1 "github.com/openshift/api/apps/v1" openshiftcontrolplanev1 "github.com/openshift/api/openshiftcontrolplane/v1" securityv1informer "github.com/openshift/client-go/security/informers/externalversions" oappsapiserver "github.com/openshift/origin/pkg/apps/apiserver" @@ -56,21 +51,8 @@ import ( userapiserver "github.com/openshift/origin/pkg/user/apiserver" "github.com/openshift/origin/pkg/version" - authorizationapiv1 "github.com/openshift/api/authorization/v1" - buildapiv1 "github.com/openshift/api/build/v1" - imageapiv1 "github.com/openshift/api/image/v1" - networkapiv1 "github.com/openshift/api/network/v1" - oauthapiv1 "github.com/openshift/api/oauth/v1" - projectapiv1 "github.com/openshift/api/project/v1" - quotaapiv1 "github.com/openshift/api/quota/v1" - routeapiv1 "github.com/openshift/api/route/v1" - securityapiv1 "github.com/openshift/api/security/v1" - templateapiv1 "github.com/openshift/api/template/v1" - userapiv1 "github.com/openshift/api/user/v1" - // register api groups _ "github.com/openshift/origin/pkg/api/install" - "github.com/openshift/origin/pkg/api/legacy" "k8s.io/client-go/restmapper" ) @@ -190,30 +172,7 @@ func (c *OpenshiftAPIConfig) Complete() completedConfig { return cfg } -// legacyStorageMutator mutates the arg to modify the RESTStorage map for legacy resources -type legacyStorageMutator interface { - mutate(map[schema.GroupVersion]map[string]rest.Storage) -} - -type legacyStorageMutators []legacyStorageMutator - -func (l legacyStorageMutators) mutate(legacyStorage map[schema.GroupVersion]map[string]rest.Storage) { - for _, curr := range l { - curr.mutate(legacyStorage) - } -} - -// this allows the storage for a given apiserver to add itself to the old /oapi endpoint's storage -type legacyStorageVersionMutator struct { - version schema.GroupVersion - storage map[string]rest.Storage -} - -func (l *legacyStorageVersionMutator) mutate(legacyStorage map[schema.GroupVersion]map[string]rest.Storage) { - legacyStorage[l.version] = l.storage -} - -func (c *completedConfig) withAppsAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withAppsAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &oappsapiserver.AppsServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: oappsapiserver.ExtraConfig{ @@ -225,18 +184,14 @@ func (c *completedConfig) withAppsAPIServer(delegateAPIServer genericapiserver.D config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: oappsapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withAuthorizationAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withAuthorizationAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &authorizationapiserver.AuthorizationAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: authorizationapiserver.ExtraConfig{ @@ -251,18 +206,14 @@ func (c *completedConfig) withAuthorizationAPIServer(delegateAPIServer genericap config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: authorizationapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withBuildAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withBuildAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &buildapiserver.BuildServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, @@ -275,18 +226,14 @@ func (c *completedConfig) withBuildAPIServer(delegateAPIServer genericapiserver. config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: buildapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withImageAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withImageAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &imageapiserver.ImageAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: imageapiserver.ExtraConfig{ @@ -303,18 +250,14 @@ func (c *completedConfig) withImageAPIServer(delegateAPIServer genericapiserver. config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: imageapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withNetworkAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withNetworkAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &networkapiserver.NetworkAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: networkapiserver.ExtraConfig{ @@ -325,18 +268,14 @@ func (c *completedConfig) withNetworkAPIServer(delegateAPIServer genericapiserve config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: networkapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withOAuthAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withOAuthAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &oauthapiserver.OAuthAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: oauthapiserver.ExtraConfig{ @@ -349,18 +288,14 @@ func (c *completedConfig) withOAuthAPIServer(delegateAPIServer genericapiserver. config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: oauthapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withProjectAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withProjectAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &projectapiserver.ProjectAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: projectapiserver.ExtraConfig{ @@ -378,18 +313,14 @@ func (c *completedConfig) withProjectAPIServer(delegateAPIServer genericapiserve config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: projectapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withQuotaAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withQuotaAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := "aapiserver.QuotaAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: quotaapiserver.ExtraConfig{ @@ -403,18 +334,14 @@ func (c *completedConfig) withQuotaAPIServer(delegateAPIServer genericapiserver. config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: quotaapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withRouteAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withRouteAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &routeapiserver.RouteAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: routeapiserver.ExtraConfig{ @@ -427,18 +354,14 @@ func (c *completedConfig) withRouteAPIServer(delegateAPIServer genericapiserver. config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: routeapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withSecurityAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withSecurityAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &securityapiserver.SecurityAPIServerConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: securityapiserver.ExtraConfig{ @@ -453,18 +376,14 @@ func (c *completedConfig) withSecurityAPIServer(delegateAPIServer genericapiserv config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: securityapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withTemplateAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withTemplateAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &templateapiserver.TemplateConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: templateapiserver.ExtraConfig{ @@ -476,18 +395,14 @@ func (c *completedConfig) withTemplateAPIServer(delegateAPIServer genericapiserv config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: templateapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -func (c *completedConfig) withUserAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) { +func (c *completedConfig) withUserAPIServer(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) { cfg := &userapiserver.UserConfig{ GenericConfig: &genericapiserver.RecommendedConfig{Config: *c.GenericConfig.Config}, ExtraConfig: userapiserver.ExtraConfig{ @@ -498,47 +413,41 @@ func (c *completedConfig) withUserAPIServer(delegateAPIServer genericapiserver.D config := cfg.Complete() server, err := config.New(delegateAPIServer) if err != nil { - return nil, nil, err - } - storage, err := config.V1RESTStorage() - if err != nil { - return nil, nil, err + return nil, err } server.GenericAPIServer.PrepareRun() // this triggers openapi construction - return server.GenericAPIServer, &legacyStorageVersionMutator{version: userapiv1.SchemeGroupVersion, storage: storage}, nil + return server.GenericAPIServer, nil } -type apiServerAppenderFunc func(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, legacyStorageMutator, error) +type apiServerAppenderFunc func(delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error) -func addAPIServerOrDie(delegateAPIServer genericapiserver.DelegationTarget, legacyStorageModifiers legacyStorageMutators, apiServerAppenderFn apiServerAppenderFunc) (genericapiserver.DelegationTarget, legacyStorageMutators) { - delegateAPIServer, currLegacyStorageMutator, err := apiServerAppenderFn(delegateAPIServer) +func addAPIServerOrDie(delegateAPIServer genericapiserver.DelegationTarget, apiServerAppenderFn apiServerAppenderFunc) genericapiserver.DelegationTarget { + delegateAPIServer, err := apiServerAppenderFn(delegateAPIServer) if err != nil { glog.Fatal(err) } - legacyStorageModifiers = append(legacyStorageModifiers, currLegacyStorageMutator) - return delegateAPIServer, legacyStorageModifiers + return delegateAPIServer } func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget, keepRemovedNetworkingAPIs bool) (*OpenshiftAPIServer, error) { delegateAPIServer := delegationTarget - legacyStorageModifier := legacyStorageMutators{} - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withAppsAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withAuthorizationAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withBuildAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withImageAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withAppsAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withAuthorizationAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withBuildAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withImageAPIServer) if keepRemovedNetworkingAPIs { - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withNetworkAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withNetworkAPIServer) } - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withOAuthAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withProjectAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withQuotaAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withRouteAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withSecurityAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withTemplateAPIServer) - delegateAPIServer, legacyStorageModifier = addAPIServerOrDie(delegateAPIServer, legacyStorageModifier, c.withUserAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withOAuthAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withProjectAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withQuotaAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withRouteAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withSecurityAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withTemplateAPIServer) + delegateAPIServer = addAPIServerOrDie(delegateAPIServer, c.withUserAPIServer) genericServer, err := c.GenericConfig.New("openshift-apiserver", delegateAPIServer) if err != nil { @@ -549,23 +458,6 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget, GenericAPIServer: genericServer, } - legacyStorage := map[schema.GroupVersion]map[string]rest.Storage{ - v1.SchemeGroupVersion: {}, - } - legacyStorageModifier.mutate(legacyStorage) - - if err := s.GenericAPIServer.InstallLegacyAPIGroup(legacy.RESTPrefix, apiLegacyV1(LegacyStorage(legacyStorage))); err != nil { - return nil, fmt.Errorf("Unable to initialize v1 API: %v", err) - } - glog.Infof("Started Origin API at %s/%s", legacy.RESTPrefix, legacy.GroupVersion.Version) - - // fix API doc string - for _, service := range s.GenericAPIServer.Handler.GoRestfulContainer.RegisteredWebServices() { - if service.RootPath() == legacy.RESTPrefix+"/"+v1.SchemeGroupVersion.Version { - service.Doc("OpenShift REST API, version v1").ApiVersion("v1") - } - } - // this remains a non-healthz endpoint so that you can be healthy without being ready. addReadinessCheckRoute(s.GenericAPIServer.Handler.NonGoRestfulMux, "/healthz/ready", c.ExtraConfig.ProjectAuthorizationCache.ReadyForAccess) @@ -607,26 +499,6 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget, return s, nil } -// apiLegacyV1 returns the resources and codec for API version v1. -func apiLegacyV1(all map[string]rest.Storage) *genericapiserver.APIGroupInfo { - apiGroupInfo := &genericapiserver.APIGroupInfo{ - PrioritizedVersions: []schema.GroupVersion{{Version: "v1"}}, - VersionedResourcesStorageMap: map[string]map[string]rest.Storage{}, - Scheme: legacyscheme.Scheme, - // version.ParameterCodec = runtime.NewParameterCodec(legacyscheme.Scheme) - ParameterCodec: legacyscheme.ParameterCodec, - NegotiatedSerializer: legacyscheme.Codecs, - } - - // TODO, just create this with lowercase names - storage := make(map[string]rest.Storage) - for k, v := range all { - storage[strings.ToLower(k)] = v - } - apiGroupInfo.VersionedResourcesStorageMap["v1"] = storage - return apiGroupInfo -} - // initReadinessCheckRoute initializes an HTTP endpoint for readiness checking func addReadinessCheckRoute(mux *genericmux.PathRecorderMux, path string, readyFunc func() bool) { mux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { diff --git a/test/integration/etcd_storage_path_test.go b/test/integration/etcd_storage_path_test.go index 38a9fe2a4c81..6f74d5f6903e 100644 --- a/test/integration/etcd_storage_path_test.go +++ b/test/integration/etcd_storage_path_test.go @@ -471,15 +471,8 @@ func TestEtcd3StoragePath(t *testing.T) { if err != nil { t.Fatal(err) } - oapiServerResources := &metav1.APIResourceList{ - GroupVersion: "v1", - } - if err := kubeClient.Discovery().RESTClient().Get().AbsPath("oapi", "v1").Do().Into(oapiServerResources); err != nil { - t.Fatal(err) - } resourcesToPersist := append( etcddata.GetResources(t, serverResources), - etcddata.GetResources(t, []*metav1.APIResourceList{oapiServerResources})..., ) for _, resourceToPersist := range resourcesToPersist {