Add pod-terminated check to kubectl-exec

Fixes https://github.com/openshift/origin/issues/8472#event-681794952
pull/6/head
Dr. Stefan Schimanski 2016-06-14 14:50:39 +02:00
parent 1aece22176
commit 734f05057e
1 changed files with 4 additions and 0 deletions

View File

@ -174,6 +174,10 @@ func (p *ExecOptions) Run() error {
return err 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 containerName := p.ContainerName
if len(containerName) == 0 { if len(containerName) == 0 {
glog.V(4).Infof("defaulting container name to %s", pod.Spec.Containers[0].Name) glog.V(4).Infof("defaulting container name to %s", pod.Spec.Containers[0].Name)