-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add request-timeout
val to oc login
restclient
#12062
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
Add request-timeout
val to oc login
restclient
#12062
Conversation
@@ -99,6 +104,16 @@ func (o *LoginOptions) getClientConfig() (*restclient.Config, error) { | |||
|
|||
clientConfig := &restclient.Config{} | |||
|
|||
// set request timeout from --request-timeout option |
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.
Is there some way to avoid copying this block of code from k8s.io/kubernetes/pkg/client/unversioned/clientcmd/client_config.go
?
@@ -99,6 +104,16 @@ func (o *LoginOptions) getClientConfig() (*restclient.Config, error) { | |||
|
|||
clientConfig := &restclient.Config{} | |||
|
|||
// set request timeout from --request-timeout option | |||
timeoutValue := kcmdutil.GetFlagString(o.Cmd, "request-timeout") |
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.
Also, this will panic if you forget the flag on any caller
pkg/cmd/cli/cmd/login/login.go
Outdated
@@ -95,6 +95,8 @@ func NewCmdLogin(fullName string, f *osclientcmd.Factory, reader io.Reader, out | |||
} | |||
|
|||
func (o *LoginOptions) Complete(f *osclientcmd.Factory, cmd *cobra.Command, args []string, commandName string) error { | |||
o.Cmd = cmd |
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 worrysome. Why do we even have this value? Options
objects shouldn't have any cobra dependencies.
@@ -66,6 +70,7 @@ type LoginOptions struct { | |||
PathOptions *kclientcmd.PathOptions | |||
|
|||
CommandName string | |||
Cmd *cobra.Command |
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.
no cobra depedencies. Pass the values you want, not magic containers.
@fabianofranz please weigh in on the severity of this issue (can we get the upstream changes in and then wait for the 1.6 rebase to fix this?) |
[test] |
@@ -66,6 +67,7 @@ type LoginOptions struct { | |||
PathOptions *kclientcmd.PathOptions | |||
|
|||
CommandName string | |||
Timeout string |
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.
pretty sure you need to honor this in dialToServer
or it won't be effective
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.
also, make this a time.Duration, not a string
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.
and call it RequestTimeout to make it clear it is per-request, not for the whole operation
@liggitt Thanks for the feedback, review comments addressed |
Yes, can wait for the 1.6 rebase. I added the |
Related upstream PR: kubernetes/kubernetes#37708 |
75d769d
to
d5acf72
Compare
integration flaked on #9203 |
conformance flaked on #9825 re[test] |
b691301
to
a9480a4
Compare
integration flake on #9379 |
…nfig-helper-for-parsing-global-timeout Automatic merge from submit-queue (batch tested with PRs 37708, 34410) Add restclientconfig helper fn for parsing timeout Related downstream PR: openshift/origin#12062 (example of use-case for this patch) **Release note**: ```release-note release-note-none ``` This patch adds a package `pkg/client/unversioned/clientcmd/util` and defines a `ParseTimeout` helper function for parsing time from a user-defined string. This allows code re-use in other packages that require the creation of a new restclient (and therefore must set the `--global-timeout` flag value manually). @fabianofranz @kubernetes/cli-review
Reminder if this PR is missed: now many 3.6 features are tested, hope this is merged/rebased when it is proper, thanks |
This patch adds a user-specified `request-timeout` flag value to the restclient that is created by `oc login`. This allows `oc login` to honor the `--request-timeout` flag. ``` $ oc login -u system:admin Logged into "https://10.13.137.149:8443" as "system:admin" using existing credentials. You have access to the following projects and can switch between them with 'oc project <projectname>': * default ... $ oc login -u system:admin --request-timeout=1ms Logged into "https://10.13.137.149:8443" as "system:admin" using existing credentials. Unable to connect to the server: net/http: request canceled (Client.Timeout exceeded while awaiting headers) ```
a9480a4
to
a684fe8
Compare
Evaluated for origin test up to a684fe8 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1642/) (Base Commit: 48e5e40) |
[merge] |
Actually |
Evaluated for origin merge up to a684fe8 |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/813/) (Base Commit: 97f1407) (Extended Tests: bug) (Image: devenv-rhel7_6277) |
UPSTREAM: kubernetes/kubernetes#37708
Fixes: #12059
This patch adds a user-specified
request-timeout
flag value to therestclient that is created by
oc login
. This allowsoc login
tohonor the
--request-timeout
flag.cc @openshift/cli-review