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

remove deploymentconfig registry #15858

Merged
merged 1 commit into from
Aug 26, 2017
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
2 changes: 0 additions & 2 deletions pkg/cmd/server/origin/master_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
kapierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/admission"
Expand Down Expand Up @@ -67,7 +66,6 @@ import (
admissionregistry "github.com/openshift/origin/pkg/cmd/server/origin/admission"
originrest "github.com/openshift/origin/pkg/cmd/server/origin/rest"
"github.com/openshift/origin/pkg/cmd/util/pluginconfig"
"github.com/openshift/origin/pkg/cmd/util/variable"
imageadmission "github.com/openshift/origin/pkg/image/admission"
imagepolicy "github.com/openshift/origin/pkg/image/admission/imagepolicy/api"
imageapi "github.com/openshift/origin/pkg/image/apis/image"
Expand Down
24 changes: 15 additions & 9 deletions pkg/cmd/server/origin/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/openshift/origin/pkg/build/webhook/github"
"github.com/openshift/origin/pkg/build/webhook/gitlab"
deployapiv1 "github.com/openshift/origin/pkg/deploy/apis/apps/v1"
deployconfigregistry "github.com/openshift/origin/pkg/deploy/registry/deployconfig"
oappsclient "github.com/openshift/origin/pkg/deploy/generated/internalclientset"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why not appsclient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: why not appsclient?

collides with upstream

deployconfigetcd "github.com/openshift/origin/pkg/deploy/registry/deployconfig/etcd"
deploylogregistry "github.com/openshift/origin/pkg/deploy/registry/deploylog"
deployconfiginstantiate "github.com/openshift/origin/pkg/deploy/registry/instantiate"
Expand Down Expand Up @@ -150,7 +150,6 @@ func (c OpenshiftAPIConfig) GetRestStorage() (map[schema.GroupVersion]map[string
if err != nil {
return nil, fmt.Errorf("error building REST storage: %v", err)
}
deployConfigRegistry := deployconfigregistry.NewRegistry(deployConfigStorage)

hostSubnetStorage, err := hostsubnetetcd.NewREST(c.GenericConfig.RESTOptionsGetter)
if err != nil {
Expand Down Expand Up @@ -260,13 +259,6 @@ func (c OpenshiftAPIConfig) GetRestStorage() (map[schema.GroupVersion]map[string
Secrets: c.KubeClientInternal.Core(),
}

deployRollbackClient := deployrollback.Client{
DCFn: deployConfigRegistry.GetDeploymentConfig,
RCFn: clientDeploymentInterface{c.KubeClientInternal}.GetDeployment,
GRFn: deployrollback.NewRollbackGenerator().GenerateRollback,
}
deployConfigRollbackStorage := deployrollback.NewREST(c.DeprecatedOpenshiftClient, c.KubeClientInternal, externalVersionCodec)

projectStorage := projectproxy.NewREST(c.KubeClientInternal.Core().Namespaces(), c.ProjectAuthorizationCache, c.ProjectAuthorizationCache, c.ProjectCache)

namespace, templateName, err := configapi.ParseNamespaceAndName(c.ProjectRequestTemplate)
Expand Down Expand Up @@ -333,6 +325,20 @@ func (c OpenshiftAPIConfig) GetRestStorage() (map[schema.GroupVersion]map[string
return nil, fmt.Errorf("error building REST storage: %v", err)
}

originAppsClient, err := oappsclient.NewForConfig(c.GenericConfig.LoopbackClientConfig)
if err != nil {
return nil, err
}
coreClient, err := kclientset.NewForConfig(c.GenericConfig.LoopbackClientConfig)
if err != nil {
return nil, err
}
deployRollbackClient := deployrollback.Client{
GRFn: deployrollback.NewRollbackGenerator().GenerateRollback,
Copy link
Contributor

Choose a reason for hiding this comment

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

@tnozicka @Kargakis reminds me you wanted to get rid of rollback generator, right?

DeploymentConfigGetter: originAppsClient.Apps(),
ReplicationControllerGetter: coreClient.Core(),
}
deployConfigRollbackStorage := deployrollback.NewREST(c.DeprecatedOpenshiftClient, c.KubeClientInternal, externalVersionCodec)
storage := map[schema.GroupVersion]map[string]rest.Storage{
v1.SchemeGroupVersion: {
// TODO: Deprecate these
Expand Down
15 changes: 8 additions & 7 deletions pkg/deploy/registry/deployconfig/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, *ScaleREST, err

statusStore := *store
statusStore.UpdateStrategy = deployconfig.StatusStrategy

statusREST := &StatusREST{store: &statusStore}
scaleREST := &ScaleREST{registry: deployconfig.NewRegistry(deploymentConfigREST)}

scaleREST := &ScaleREST{store: store}

return deploymentConfigREST, statusREST, scaleREST, nil
}

// ScaleREST contains the REST storage for the Scale subresource of DeploymentConfigs.
type ScaleREST struct {
registry deployconfig.Registry
store *registry.Store
}

// ScaleREST implements Patcher
Expand All @@ -73,20 +73,21 @@ func (r *ScaleREST) New() runtime.Object {

// Get retrieves (computes) the Scale subresource for the given DeploymentConfig name.
func (r *ScaleREST) Get(ctx apirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
deploymentConfig, err := r.registry.GetDeploymentConfig(ctx, name, options)
deploymentConfig, err := r.store.Get(ctx, name, options)
if err != nil {
return nil, err
}

return deployapi.ScaleFromConfig(deploymentConfig), nil
return deployapi.ScaleFromConfig(deploymentConfig.(*deployapi.DeploymentConfig)), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

i guess we don't need to check this assertion?

}

// Update scales the DeploymentConfig for the given Scale subresource, returning the updated Scale.
func (r *ScaleREST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
deploymentConfig, err := r.registry.GetDeploymentConfig(ctx, name, &metav1.GetOptions{})
uncastObj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
if err != nil {
return nil, false, errors.NewNotFound(extensions.Resource("scale"), name)
}
deploymentConfig := uncastObj.(*deployapi.DeploymentConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check?

It would be programmer error. I don't feel too bad about panic-ing here.


old := deployapi.ScaleFromConfig(deploymentConfig)
obj, err := objInfo.UpdatedObject(ctx, old)
Expand All @@ -104,7 +105,7 @@ func (r *ScaleREST) Update(ctx apirequest.Context, name string, objInfo rest.Upd
}

deploymentConfig.Spec.Replicas = scale.Spec.Replicas
if err := r.registry.UpdateDeploymentConfig(ctx, deploymentConfig); err != nil {
if _, _, err := r.store.Update(ctx, deploymentConfig.Name, rest.DefaultUpdatedObjectInfo(deploymentConfig, kapi.Scheme)); err != nil {
return nil, false, err
}

Expand Down
135 changes: 0 additions & 135 deletions pkg/deploy/registry/deployconfig/etcd/etcd_test.go

This file was deleted.

68 changes: 0 additions & 68 deletions pkg/deploy/registry/deployconfig/registry.go

This file was deleted.

16 changes: 7 additions & 9 deletions pkg/deploy/registry/rollback/rest_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
apirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
kapi "k8s.io/kubernetes/pkg/api"
coreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"

deployapi "github.com/openshift/origin/pkg/deploy/apis/apps"
"github.com/openshift/origin/pkg/deploy/apis/apps/validation"
deployclient "github.com/openshift/origin/pkg/deploy/generated/internalclientset/typed/apps/internalversion"
deployutil "github.com/openshift/origin/pkg/deploy/util"
)

Expand All @@ -31,24 +33,20 @@ type GeneratorClient interface {
GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error)
}

// Client provides an implementation of Generator client
type Client struct {
GRFn func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error)
RCFn func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error)
DCFn func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error)
GRFn func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error)
DeploymentConfigGetter deployclient.DeploymentConfigsGetter
ReplicationControllerGetter coreclient.ReplicationControllersGetter
}

// GetDeployment returns the deploymentConfig with the provided context and name
func (c Client) GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) {
return c.DCFn(ctx, name, options)
return c.DeploymentConfigGetter.DeploymentConfigs(apirequest.NamespaceValue(ctx)).Get(name, *options)
}

// GetDeployment returns the deployment with the provided context and name
func (c Client) GetDeployment(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) {
return c.RCFn(ctx, name, options)
return c.ReplicationControllerGetter.ReplicationControllers(apirequest.NamespaceValue(ctx)).Get(name, *options)
}

// GenerateRollback generates a new deploymentConfig by merging a pair of deploymentConfigs
func (c Client) GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) {
return c.GRFn(from, to, spec)
}
Expand Down
Loading