Commit ebe4ce16 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #24366 from janetkuo/kubectl-run-session-hint

Automatic merge from submit-queue Fix session ended hint for kubectl run Fixes #23602 Before: ```console $ kubectl run -i --tty busybox --image=busybox Waiting for pod default/busybox-3797442026-mt8zk to be running, status is Pending, pod ready: false Hit enter for command prompt / # / # exit Session ended, resume using ' busybox-3797442026-mt8zk -c busybox -i -t' command when the pod is running ↑ (incomplete command) ``` After: ```console Session ended, resume using 'kubectl attach busybox-3797442026-mt8zk -c busybox -i -t' command when the pod is running ``` @kubernetes/kubectl
parents 327d32dc fe4b16c8
...@@ -343,6 +343,7 @@ func handleAttachPod(f *cmdutil.Factory, c *client.Client, pod *api.Pod, opts *A ...@@ -343,6 +343,7 @@ func handleAttachPod(f *cmdutil.Factory, c *client.Client, pod *api.Pod, opts *A
opts.Client = c opts.Client = c
opts.PodName = pod.Name opts.PodName = pod.Name
opts.Namespace = pod.Namespace opts.Namespace = pod.Namespace
opts.CommandName = "kubectl attach"
if err := opts.Run(); err != nil { if err := opts.Run(); err != nil {
fmt.Fprintf(opts.Out, "Error attaching, falling back to logs: %v\n", err) fmt.Fprintf(opts.Out, "Error attaching, falling back to logs: %v\n", err)
req, err := f.LogsForObject(pod, &api.PodLogOptions{Container: opts.GetContainerName(pod)}) req, err := f.LogsForObject(pod, &api.PodLogOptions{Container: opts.GetContainerName(pod)})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment