diff --git a/contrib/completions/bash/oc b/contrib/completions/bash/oc index 4621fc863638..f79a7884553d 100644 --- a/contrib/completions/bash/oc +++ b/contrib/completions/bash/oc @@ -11720,6 +11720,8 @@ _oc_rsh() local_nonpersistent_flags+=("--no-tty") flags+=("--shell=") local_nonpersistent_flags+=("--shell=") + flags+=("--timeout=") + local_nonpersistent_flags+=("--timeout=") flags+=("--tty") flags+=("-t") local_nonpersistent_flags+=("--tty") diff --git a/contrib/completions/bash/openshift b/contrib/completions/bash/openshift index 006f44a87bd9..b6f50b25fc66 100644 --- a/contrib/completions/bash/openshift +++ b/contrib/completions/bash/openshift @@ -16285,6 +16285,8 @@ _openshift_cli_rsh() local_nonpersistent_flags+=("--no-tty") flags+=("--shell=") local_nonpersistent_flags+=("--shell=") + flags+=("--timeout=") + local_nonpersistent_flags+=("--timeout=") flags+=("--tty") flags+=("-t") local_nonpersistent_flags+=("--tty") diff --git a/contrib/completions/zsh/oc b/contrib/completions/zsh/oc index 8cfe7493f4f2..33f32ffd0162 100644 --- a/contrib/completions/zsh/oc +++ b/contrib/completions/zsh/oc @@ -11882,6 +11882,8 @@ _oc_rsh() local_nonpersistent_flags+=("--no-tty") flags+=("--shell=") local_nonpersistent_flags+=("--shell=") + flags+=("--timeout=") + local_nonpersistent_flags+=("--timeout=") flags+=("--tty") flags+=("-t") local_nonpersistent_flags+=("--tty") diff --git a/contrib/completions/zsh/openshift b/contrib/completions/zsh/openshift index 0b82d60044d5..a5dca49ead65 100644 --- a/contrib/completions/zsh/openshift +++ b/contrib/completions/zsh/openshift @@ -16447,6 +16447,8 @@ _openshift_cli_rsh() local_nonpersistent_flags+=("--no-tty") flags+=("--shell=") local_nonpersistent_flags+=("--shell=") + flags+=("--timeout=") + local_nonpersistent_flags+=("--timeout=") flags+=("--tty") flags+=("-t") local_nonpersistent_flags+=("--tty") diff --git a/docs/man/man1/oc-rsh.1 b/docs/man/man1/oc-rsh.1 index 084ce7c099e1..2f58b9f8ab11 100644 --- a/docs/man/man1/oc-rsh.1 +++ b/docs/man/man1/oc-rsh.1 @@ -44,6 +44,10 @@ directly. \fB\-\-shell\fP="/bin/sh" Path to the shell command +.PP +\fB\-\-timeout\fP=10 + Request timeout for obtaining a pod from the server; defaults to 10 seconds + .PP \fB\-t\fP, \fB\-\-tty\fP=false Force a pseudo\-terminal to be allocated diff --git a/docs/man/man1/openshift-cli-rsh.1 b/docs/man/man1/openshift-cli-rsh.1 index 2a4cf999c0c7..b4651933aa15 100644 --- a/docs/man/man1/openshift-cli-rsh.1 +++ b/docs/man/man1/openshift-cli-rsh.1 @@ -44,6 +44,10 @@ directly. \fB\-\-shell\fP="/bin/sh" Path to the shell command +.PP +\fB\-\-timeout\fP=10 + Request timeout for obtaining a pod from the server; defaults to 10 seconds + .PP \fB\-t\fP, \fB\-\-tty\fP=false Force a pseudo\-terminal to be allocated diff --git a/pkg/cmd/cli/cmd/rsh.go b/pkg/cmd/cli/cmd/rsh.go index 30291e11059e..de929ca03a5a 100644 --- a/pkg/cmd/cli/cmd/rsh.go +++ b/pkg/cmd/cli/cmd/rsh.go @@ -53,6 +53,7 @@ type RshOptions struct { ForceTTY bool DisableTTY bool Executable string + Timeout int *kubecmd.ExecOptions } @@ -61,6 +62,7 @@ func NewCmdRsh(name string, parent string, f *clientcmd.Factory, in io.Reader, o options := &RshOptions{ ForceTTY: false, DisableTTY: false, + Timeout: 10, ExecOptions: &kubecmd.ExecOptions{ StreamOptions: kubecmd.StreamOptions{ In: in, @@ -89,6 +91,7 @@ func NewCmdRsh(name string, parent string, f *clientcmd.Factory, in io.Reader, o cmd.Flags().BoolVarP(&options.ForceTTY, "tty", "t", false, "Force a pseudo-terminal to be allocated") cmd.Flags().BoolVarP(&options.DisableTTY, "no-tty", "T", false, "Disable pseudo-terminal allocation") cmd.Flags().StringVar(&options.Executable, "shell", "/bin/sh", "Path to the shell command") + cmd.Flags().IntVar(&options.Timeout, "timeout", 10, "Request timeout for obtaining a pod from the server; defaults to 10 seconds") cmd.Flags().StringVarP(&options.ContainerName, "container", "c", "", "Container name; defaults to first container") cmd.Flags().SetInterspersed(false) return cmd @@ -136,8 +139,7 @@ func (o *RshOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []s } o.Client = client - // TODO: Consider making the timeout configurable - o.PodName, err = f.PodForResource(resource, 10*time.Second) + o.PodName, err = f.PodForResource(resource, time.Duration(o.Timeout)*time.Second) return err }