mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 21:25:09 +00:00
Add pod-terminated check to kubectl-exec
Fixes https://github.com/openshift/origin/issues/8472#event-681794952
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user