From 3a3421b74228119597c6c5d734af19909a0d95d4 Mon Sep 17 00:00:00 2001 From: feihujiang Date: Thu, 10 Dec 2015 15:51:07 +0800 Subject: [PATCH] Print how to reattch to seesion when session ends --- pkg/kubectl/cmd/attach.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/kubectl/cmd/attach.go b/pkg/kubectl/cmd/attach.go index 889c13a6b88..ad22ef460e0 100644 --- a/pkg/kubectl/cmd/attach.go +++ b/pkg/kubectl/cmd/attach.go @@ -221,7 +221,14 @@ func (p *AttachOptions) Run() error { TTY: tty, }, api.Scheme) - return p.Attach.Attach("POST", req.URL(), p.Config, stdin, p.Out, p.Err, tty) + err = p.Attach.Attach("POST", req.URL(), p.Config, stdin, p.Out, p.Err, tty) + if err != nil { + return err + } + if p.Stdin && tty && pod.Spec.RestartPolicy == api.RestartPolicyAlways { + fmt.Fprintf(p.Out, "Session ended, resume using 'kubectl attach %s -c %s -i -t' command when the pod is running\n", pod.Name, containerToAttach.Name) + } + return nil } // GetContainer returns the container to attach to, with a fallback.