Skip to content

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

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Nov 29, 2016

UPSTREAM: kubernetes/kubernetes#37708
Fixes: #12059

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)

cc @openshift/cli-review

@@ -99,6 +104,16 @@ func (o *LoginOptions) getClientConfig() (*restclient.Config, error) {

clientConfig := &restclient.Config{}

// set request timeout from --request-timeout option
Copy link
Contributor

@ncdc ncdc Nov 29, 2016

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")
Copy link
Contributor

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

@@ -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
Copy link
Contributor

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
Copy link
Contributor

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.

@juanvallejo
Copy link
Contributor Author

@ncdc @deads2k Thanks for the review, will add upstream PR if new changes are okay

@ncdc
Copy link
Contributor

ncdc commented Nov 29, 2016

@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?)

@juanvallejo
Copy link
Contributor Author

[test]

@@ -66,6 +67,7 @@ type LoginOptions struct {
PathOptions *kclientcmd.PathOptions

CommandName string
Timeout string
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

@juanvallejo
Copy link
Contributor Author

@liggitt Thanks for the feedback, review comments addressed

@fabianofranz
Copy link
Member

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?)

Yes, can wait for the 1.6 rebase. I added the post-rebase label in the original issue and this PR, @juanvallejo please add the upstream PR link in a comment when opened. Tks!

@juanvallejo
Copy link
Contributor Author

Related upstream PR: kubernetes/kubernetes#37708

@juanvallejo juanvallejo force-pushed the jvallejo/add-request-timeout-val-to-oc-login-restclient branch from 75d769d to d5acf72 Compare November 30, 2016 19:25
@juanvallejo
Copy link
Contributor Author

integration flaked on #9203
re[test]

@juanvallejo
Copy link
Contributor Author

networking flake on #11452
conformance flake on #9203
re[test]

@juanvallejo
Copy link
Contributor Author

conformance flaked on #9825 re[test]

@juanvallejo juanvallejo force-pushed the jvallejo/add-request-timeout-val-to-oc-login-restclient branch 2 times, most recently from b691301 to a9480a4 Compare December 1, 2016 20:54
@juanvallejo
Copy link
Contributor Author

integration flake on #9379
re[test]

k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Dec 14, 2016
…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
@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 1, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 16, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 23, 2017
@xingxingxia
Copy link

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)
```
@juanvallejo juanvallejo force-pushed the jvallejo/add-request-timeout-val-to-oc-login-restclient branch from a9480a4 to a684fe8 Compare May 23, 2017 16:26
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to a684fe8

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 23, 2017
@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1642/) (Base Commit: 48e5e40)

@juanvallejo juanvallejo requested a review from fabianofranz May 24, 2017 18:59
@fabianofranz
Copy link
Member

[merge]

@fabianofranz
Copy link
Member

Actually
[merge][severity: bug]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to a684fe8

@openshift-bot
Copy link
Contributor

openshift-bot commented May 26, 2017

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)

@openshift-bot openshift-bot merged commit f703da4 into openshift:master May 26, 2017
@juanvallejo juanvallejo deleted the jvallejo/add-request-timeout-val-to-oc-login-restclient branch May 31, 2017 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/cli kind/bug Categorizes issue or PR as related to a bug. kind/post-rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants