From 734f05057edc874aa19d0421eb6fa0cd648c7f99 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Tue, 14 Jun 2016 14:50:39 +0200 Subject: [PATCH] Add pod-terminated check to kubectl-exec Fixes https://github.com/openshift/origin/issues/8472#event-681794952 --- pkg/kubectl/cmd/exec.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/kubectl/cmd/exec.go b/pkg/kubectl/cmd/exec.go index 7484afa219..522aec181f 100644 --- a/pkg/kubectl/cmd/exec.go +++ b/pkg/kubectl/cmd/exec.go @@ -174,6 +174,10 @@ func (p *ExecOptions) Run() error { return err } + if pod.Status.Phase == api.PodSucceeded || pod.Status.Phase == api.PodFailed { + return fmt.Errorf("cannot exec into a container in a completed pod; current phase is %s", pod.Status.Phase) + } + containerName := p.ContainerName if len(containerName) == 0 { glog.V(4).Infof("defaulting container name to %s", pod.Spec.Containers[0].Name)