Skip to content

Commit 01635f3

Browse files
Merge pull request #15858 from deads2k/server-33-storage
Automatic merge from submit-queue (batch tested with PRs 15942, 15940, 15957, 15858, 15946) remove deploymentconfig registry Remove more registry dependencies from "easy" resources.
2 parents f29206e + 0d12974 commit 01635f3

File tree

8 files changed

+58
-364
lines changed

8 files changed

+58
-364
lines changed

pkg/cmd/server/origin/storage.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/openshift/origin/pkg/build/webhook/github"
3131
"github.com/openshift/origin/pkg/build/webhook/gitlab"
3232
deployapiv1 "github.com/openshift/origin/pkg/deploy/apis/apps/v1"
33-
deployconfigregistry "github.com/openshift/origin/pkg/deploy/registry/deployconfig"
33+
oappsclient "github.com/openshift/origin/pkg/deploy/generated/internalclientset"
3434
deployconfigetcd "github.com/openshift/origin/pkg/deploy/registry/deployconfig/etcd"
3535
deploylogregistry "github.com/openshift/origin/pkg/deploy/registry/deploylog"
3636
deployconfiginstantiate "github.com/openshift/origin/pkg/deploy/registry/instantiate"
@@ -150,7 +150,6 @@ func (c OpenshiftAPIConfig) GetRestStorage() (map[schema.GroupVersion]map[string
150150
if err != nil {
151151
return nil, fmt.Errorf("error building REST storage: %v", err)
152152
}
153-
deployConfigRegistry := deployconfigregistry.NewRegistry(deployConfigStorage)
154153

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

263-
deployRollbackClient := deployrollback.Client{
264-
DCFn: deployConfigRegistry.GetDeploymentConfig,
265-
RCFn: clientDeploymentInterface{c.KubeClientInternal}.GetDeployment,
266-
GRFn: deployrollback.NewRollbackGenerator().GenerateRollback,
267-
}
268-
deployConfigRollbackStorage := deployrollback.NewREST(c.DeprecatedOpenshiftClient, c.KubeClientInternal, externalVersionCodec)
269-
270262
projectStorage := projectproxy.NewREST(c.KubeClientInternal.Core().Namespaces(), c.ProjectAuthorizationCache, c.ProjectAuthorizationCache, c.ProjectCache)
271263

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

328+
originAppsClient, err := oappsclient.NewForConfig(c.GenericConfig.LoopbackClientConfig)
329+
if err != nil {
330+
return nil, err
331+
}
332+
coreClient, err := kclientset.NewForConfig(c.GenericConfig.LoopbackClientConfig)
333+
if err != nil {
334+
return nil, err
335+
}
336+
deployRollbackClient := deployrollback.Client{
337+
GRFn: deployrollback.NewRollbackGenerator().GenerateRollback,
338+
DeploymentConfigGetter: originAppsClient.Apps(),
339+
ReplicationControllerGetter: coreClient.Core(),
340+
}
341+
deployConfigRollbackStorage := deployrollback.NewREST(c.DeprecatedOpenshiftClient, c.KubeClientInternal, externalVersionCodec)
336342
storage := map[schema.GroupVersion]map[string]rest.Storage{
337343
v1.SchemeGroupVersion: {
338344
// TODO: Deprecate these

pkg/deploy/registry/deployconfig/etcd/etcd.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, *ScaleREST, err
5151

5252
statusStore := *store
5353
statusStore.UpdateStrategy = deployconfig.StatusStrategy
54-
5554
statusREST := &StatusREST{store: &statusStore}
56-
scaleREST := &ScaleREST{registry: deployconfig.NewRegistry(deploymentConfigREST)}
55+
56+
scaleREST := &ScaleREST{store: store}
5757

5858
return deploymentConfigREST, statusREST, scaleREST, nil
5959
}
6060

6161
// ScaleREST contains the REST storage for the Scale subresource of DeploymentConfigs.
6262
type ScaleREST struct {
63-
registry deployconfig.Registry
63+
store *registry.Store
6464
}
6565

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

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

81-
return deployapi.ScaleFromConfig(deploymentConfig), nil
81+
return deployapi.ScaleFromConfig(deploymentConfig.(*deployapi.DeploymentConfig)), nil
8282
}
8383

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

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

106107
deploymentConfig.Spec.Replicas = scale.Spec.Replicas
107-
if err := r.registry.UpdateDeploymentConfig(ctx, deploymentConfig); err != nil {
108+
if _, _, err := r.store.Update(ctx, deploymentConfig.Name, rest.DefaultUpdatedObjectInfo(deploymentConfig, kapi.Scheme)); err != nil {
108109
return nil, false, err
109110
}
110111

pkg/deploy/registry/deployconfig/etcd/etcd_test.go

Lines changed: 0 additions & 135 deletions
This file was deleted.

pkg/deploy/registry/deployconfig/registry.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

pkg/deploy/registry/rollback/rest_deprecated.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
apirequest "k8s.io/apiserver/pkg/endpoints/request"
1111
"k8s.io/apiserver/pkg/registry/rest"
1212
kapi "k8s.io/kubernetes/pkg/api"
13+
coreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
1314

1415
deployapi "github.com/openshift/origin/pkg/deploy/apis/apps"
1516
"github.com/openshift/origin/pkg/deploy/apis/apps/validation"
17+
deployclient "github.com/openshift/origin/pkg/deploy/generated/internalclientset/typed/apps/internalversion"
1618
deployutil "github.com/openshift/origin/pkg/deploy/util"
1719
)
1820

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

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

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

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

51-
// GenerateRollback generates a new deploymentConfig by merging a pair of deploymentConfigs
5250
func (c Client) GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) {
5351
return c.GRFn(from, to, spec)
5452
}

0 commit comments

Comments
 (0)