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

apps: switch to use generated internal clientset #16100

Merged
merged 3 commits into from
Sep 5, 2017

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Sep 1, 2017

This PR replaces the legacy pkg/client in pkg/deploy. It switches controllers and storage to use the generated internal clientset.

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 1, 2017
@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-api-review labels Sep 1, 2017
OpenshiftInternalTemplateClient(name string) (templateclient.Interface, error)
OpenshiftInternalTemplateClientOrDie(name string) templateclient.Interface

OpenshiftInternalImageClient(name string) (imageclientinternal.Interface, error)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k @soltysh minor, but I like this naming scheme better:

OpenShift[Internal|External]Client

It matches the kube client scheme and allow us to add external clients in future...

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k @soltysh minor, but I like this naming scheme better:

OpenShift[Internal|External]Client

It matches the kube client scheme and allow us to add external clients in future...

ok

Copy link
Member

Choose a reason for hiding this comment

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

On a side not, I still wonder if we need both *Client and *ClientOrDie if we use the latter in all places that I've searched for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@soltysh the apiserver use the *Client version to report errors properly, we need both.

@@ -102,7 +103,11 @@ func (c *AppsConfig) newV1RESTStorage() (map[string]rest.Storage, error) {
// TODO sort out who is using this and why. it was hardcoded before the migration and I suspect that it is being used
// to serialize out objects into annotations.
externalVersionCodec := kapi.Codecs.LegacyCodec(schema.GroupVersion{Group: "", Version: "v1"})
deprecatedOpenshiftClient, err := osclient.New(c.GenericConfig.LoopbackClientConfig)
openshiftInternalAppsClient, err := appsclientinternal.NewForConfig(c.CoreAPIServerClientConfig)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k this almost looks like a job for ClientBuilder :-) (but I don't really think we should use the controller.ClientBuilder here, maybe just create something similar for GenericServer ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k this almost looks like a job for ClientBuilder :-) (but I don't really think we should use the controller.ClientBuilder here, maybe just create something similar for GenericServer ?

The client builder is special because it goes and gets different credentials. I don't think this server needs to get different credentials to run

@mfojtik mfojtik changed the title apps: switch to use generated internal clientset WIP: apps: switch to use generated internal clientset Sep 1, 2017
@@ -102,7 +103,11 @@ func (c *AppsConfig) newV1RESTStorage() (map[string]rest.Storage, error) {
// TODO sort out who is using this and why. it was hardcoded before the migration and I suspect that it is being used
// to serialize out objects into annotations.
externalVersionCodec := kapi.Codecs.LegacyCodec(schema.GroupVersion{Group: "", Version: "v1"})
deprecatedOpenshiftClient, err := osclient.New(c.GenericConfig.LoopbackClientConfig)
openshiftInternalAppsClient, err := appsclientinternal.NewForConfig(c.CoreAPIServerClientConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

This connection can be based on the loopback clientconfig (see previous). It doesn't have to go through the coreapiserver.

if err != nil {
return nil, err
}
openshiftInternalImageClient, err := imageclientinternal.NewForConfig(c.CoreAPIServerClientConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

this one is using the correct clientconfig, since the apps server doesn't host images.

Copy link
Member

Choose a reason for hiding this comment

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

We should probably write it down for others to be aware of that rule, for the future time where we'll split each group into its own apiserver.

@deads2k
Copy link
Contributor

deads2k commented Sep 1, 2017

lgtm so far

@mfojtik mfojtik force-pushed the deploy-clientset branch 4 times, most recently from 60ac32f to 88d4bd7 Compare September 1, 2017 22:22
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 1, 2017
@mfojtik mfojtik changed the title WIP: apps: switch to use generated internal clientset apps: switch to use generated internal clientset Sep 1, 2017
@mfojtik
Copy link
Contributor Author

mfojtik commented Sep 1, 2017

@deads2k @tnozicka PTAL - this is now ready, tests should be green.

@0xmichalis
Copy link
Contributor

/lint

Copy link

@openshift-ci-robot openshift-ci-robot left a comment

Choose a reason for hiding this comment

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

@Kargakis: 8 warnings.

In response to this:

/lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

)

func NewREST(store registry.Store, oc client.Interface, kc kclientset.Interface, decoder runtime.Decoder, admission admission.Interface) *REST {
func NewREST(store registry.Store, imagesclient imageclientinternal.Interface, kc kclientset.Interface, decoder runtime.Decoder, admission admission.Interface) *REST {

Choose a reason for hiding this comment

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

Golint comments: exported function NewREST should have comment or be unexported. More info.

@@ -99,32 +108,48 @@ func (b OpenshiftControllerClientBuilder) DeprecatedOpenshiftClientOrDie(name st
return client
}

func (b OpenshiftControllerClientBuilder) OpenshiftTemplateClient(name string) (templateclient.Interface, error) {
func (b OpenshiftControllerClientBuilder) OpenshiftInternalTemplateClient(name string) (templateclient.Interface, error) {

Choose a reason for hiding this comment

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

Golint comments: exported method OpenshiftControllerClientBuilder.OpenshiftInternalTemplateClient should have comment or be unexported. More info.

clientConfig, err := b.Config(name)
if err != nil {
return nil, err
}
return templateclient.NewForConfig(clientConfig)
}

func (b OpenshiftControllerClientBuilder) OpenshiftTemplateClientOrDie(name string) templateclient.Interface {
client, err := b.OpenshiftTemplateClient(name)
func (b OpenshiftControllerClientBuilder) OpenshiftInternalTemplateClientOrDie(name string) templateclient.Interface {

Choose a reason for hiding this comment

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

Golint comments: exported method OpenshiftControllerClientBuilder.OpenshiftInternalTemplateClientOrDie should have comment or be unexported. More info.

return client
}

func (b OpenshiftControllerClientBuilder) OpenshiftInternalImageClient(name string) (imageclientinternal.Interface, error) {

Choose a reason for hiding this comment

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

Golint comments: exported method OpenshiftControllerClientBuilder.OpenshiftInternalImageClient should have comment or be unexported. More info.

return imageclientinternal.NewForConfig(clientConfig)
}

func (b OpenshiftControllerClientBuilder) OpenshiftInternalImageClientOrDie(name string) imageclientinternal.Interface {

Choose a reason for hiding this comment

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

Golint comments: exported method OpenshiftControllerClientBuilder.OpenshiftInternalImageClientOrDie should have comment or be unexported. More info.

if err != nil {
glog.Fatal(err)
}
return client
}

func (b OpenshiftControllerClientBuilder) OpenshiftImageClient(name string) (imageclient.Interface, error) {
func (b OpenshiftControllerClientBuilder) OpenshiftInternalAppsClient(name string) (appsclientinternal.Interface, error) {

Choose a reason for hiding this comment

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

Golint comments: exported method OpenshiftControllerClientBuilder.OpenshiftInternalAppsClient should have comment or be unexported. More info.

}

func (b OpenshiftControllerClientBuilder) OpenshiftImageClientOrDie(name string) imageclient.Interface {
client, err := b.OpenshiftImageClient(name)
func (b OpenshiftControllerClientBuilder) OpenshiftInternalAppsClientOrDie(name string) appsclientinternal.Interface {

Choose a reason for hiding this comment

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

Golint comments: exported method OpenshiftControllerClientBuilder.OpenshiftInternalAppsClientOrDie should have comment or be unexported. More info.

@@ -64,6 +64,14 @@ func GetClusterAdminClientConfig(adminKubeConfigFile string) (*restclient.Config
return conf, nil
}

func GetClusterAdminClientConfigOrDie(adminKubeConfigFile string) *restclient.Config {

Choose a reason for hiding this comment

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

Golint comments: exported function GetClusterAdminClientConfigOrDie should have comment or be unexported. More info.

@mfojtik
Copy link
Contributor Author

mfojtik commented Sep 4, 2017

all linter comments fixed

@tnozicka @deads2k @Kargakis PTAL (tests should be green).

Copy link
Contributor

@tnozicka tnozicka left a comment

Choose a reason for hiding this comment

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

nits, lgtm

if err != nil {
return nil, err
}
// This client is using the core api server cient config, since the apps server doesn't host images
Copy link
Contributor

Choose a reason for hiding this comment

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

s/cient/client

@@ -406,7 +407,7 @@ func TestImageStreamTagLifecycleHook(t *testing.T) {
}

// can tag to a stream that exists
exec := stratsupport.NewHookExecutor(nil, clusterAdminClient, clusterAdminKubeClientset.Core(), os.Stdout, kapi.Codecs.UniversalDecoder())
exec := stratsupport.NewHookExecutor(nil, imageclient.NewForConfigOrDie(testutil.GetClusterAdminClientConfigOrDie(clusterAdminKubeConfig)), clusterAdminKubeClientset.Core(), os.Stdout, kapi.Codecs.UniversalDecoder())
Copy link
Contributor

Choose a reason for hiding this comment

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

@mfojtik can you extract imageclient.NewForConfigOrDie(testutil.GetClusterAdminClientConfigOrDie(clusterAdminKubeConfig)) into a variable and not create it 3 times?

@0xmichalis
Copy link
Contributor

/shrug

@openshift-ci-robot openshift-ci-robot added the ¯\_(ツ)_/¯ ¯\\\_(ツ)_/¯ label Sep 4, 2017
@0xmichalis
Copy link
Contributor

/unshrug

@openshift-ci-robot
Copy link

@Kargakis: ¯\_(ツ)_/¯

In response to this:

/unshrug

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot removed the ¯\_(ツ)_/¯ ¯\\\_(ツ)_/¯ label Sep 4, 2017
@mfojtik
Copy link
Contributor Author

mfojtik commented Sep 4, 2017

/retest

1 similar comment
@mfojtik
Copy link
Contributor Author

mfojtik commented Sep 4, 2017

/retest

@mfojtik
Copy link
Contributor Author

mfojtik commented Sep 4, 2017

/retest

@@ -420,8 +420,8 @@ var createSubresourceTemplate = `
// Create takes the representation of a $.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
func (c *Fake$.type|publicPlural$) Create($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
obj, err := c.Fake.
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.inputType|raw${})
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the deal here? This is fixed in upstream already? Why not pick that one back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is fixed in upstream PR, unfortunately after the downstream merged....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k so this will be a drop on rebase because the original upstream change include this fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k so this will be a drop on rebase because the original upstream change include this fix.

ok

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

One question, otherwise lgtm

$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.inputType|raw${})
$else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.inputType|raw${})$end$
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.resultType|raw${})
$else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$
Copy link
Member

Choose a reason for hiding this comment

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

Why only this part and not entire kubernetes/kubernetes#51638?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what are you asking. that part is already merged :)

@deads2k
Copy link
Contributor

deads2k commented Sep 5, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, mfojtik

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@deads2k
Copy link
Contributor

deads2k commented Sep 5, 2017

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 16142, 16100, 16109, 16113, 16117)

@openshift-merge-robot openshift-merge-robot merged commit f1d3d0d into openshift:master Sep 5, 2017
openshift-merge-robot added a commit that referenced this pull request Sep 6, 2017
Automatic merge from submit-queue

apps: replace legacy client with generated in pkg/deploy/cmd

Ignore first 3 commits, they are part of #16100

@deads2k last bits in apps group
@mfojtik mfojtik deleted the deploy-clientset branch September 5, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants