kubernetes: sessions of `kubectl exec -ti` on `shareProcessNamespace` do not get closed when pod is deleted

What happened:

Created a pod with shareProcessNamespace: true. Used kubectl exec into that pod. Deleted the pod. Session hung - ^C, ^Z do not work. Had to kill -9 from another terminal. Changing shareProcessNamespace to false does not have this problem.

What you expected to happen:

Session to terminate.

How to reproduce it (as minimally and precisely as possible):

Create this pod:

apiVersion: v1
kind: Pod 
metadata:
  annotations:
  name: shared-pid
spec:
  containers:
  - image: ubuntu
    name: c1
    command:
      - bash
      - -c
      - "trap 'date > /tmp/sigterm' SIGTERM; while true; do sleep 1; done"
  restartPolicy: Never                                                                                                                                                         
  terminationGracePeriodSeconds: 60
  shareProcessNamespace: true

Environment:

  • Kubernetes version (use kubectl version): Client Version: version.Info{Major:“1”, Minor:“18+”, GitVersion:"v1.18.0-alpha.1.359+c409446d41924b-dirty

  • Cloud provider or hardware configuration: GCP, not GKE

  • OS (e.g: cat /etc/os-release): Google COS

  • Kernel (e.g. uname -a): 4.19.76+

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

WONT-FIX. dockershim is going away.

The issue is still reproduced at master.

$ kubectl exec -it shared-pid -- /bin/bash
root@shared-pid:/# 
root@shared-pid:/#
$ kubectl exec -it non-shared-pid -- /bin/bash
root@non-shared-pid:/# 
root@non-shared-pid:/# command terminated with exit code 137

/triage accepted