-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
apps: switch to use generated internal clientset #16100
Conversation
OpenshiftInternalTemplateClient(name string) (templateclient.Interface, error) | ||
OpenshiftInternalTemplateClientOrDie(name string) templateclient.Interface | ||
|
||
OpenshiftInternalImageClient(name string) (imageclientinternal.Interface, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pkg/deploy/apiserver/apiserver.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
pkg/deploy/apiserver/apiserver.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
pkg/deploy/apiserver/apiserver.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
openshiftInternalImageClient, err := imageclientinternal.NewForConfig(c.CoreAPIServerClientConfig) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lgtm so far |
60ac32f
to
88d4bd7
Compare
/lint |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
test/util/client.go
Outdated
@@ -64,6 +64,14 @@ func GetClusterAdminClientConfig(adminKubeConfigFile string) (*restclient.Config | |||
return conf, nil | |||
} | |||
|
|||
func GetClusterAdminClientConfigOrDie(adminKubeConfigFile string) *restclient.Config { |
There was a problem hiding this comment.
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.
88d4bd7
to
ef6504d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits, lgtm
pkg/deploy/apiserver/apiserver.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
// This client is using the core api server cient config, since the apps server doesn't host images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/cient/client
test/integration/imagestream_test.go
Outdated
@@ -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()) |
There was a problem hiding this comment.
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?
/shrug |
/unshrug |
@Kargakis: ¯\_(ツ)_/¯ In response to this:
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. |
/retest |
1 similar comment
/retest |
ef6504d
to
f11ddbf
Compare
/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${}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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$ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
/lgtm |
[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 |
/retest |
Automatic merge from submit-queue (batch tested with PRs 16142, 16100, 16109, 16113, 16117) |
This PR replaces the legacy pkg/client in pkg/deploy. It switches controllers and storage to use the generated internal clientset.