kubernetes: Deleting pod: exited containers marked as running until last one exits

What happened: I have two container running. When deleting the pod containing them, both containers remain in state running until the last one has exited.

What you expected to happen: The first container to shutdown gracefully should be marked as completed as soon as it exits.

How to reproduce it (as minimally and precisely as possible): Run the following pod, and delete it. The one which exits after 10 seconds continues to claim it is running, even though it has exited.

apiVersion: v1
kind: Pod
metadata:
  name: test-termination
  namespace: default
spec:
  restartPolicy: Never
  terminationGracePeriodSeconds: 60
  containers:
    - name: short-terminate
      image: "alpine:3.9.5"
      resources:
        limits:
          cpu: 0.1
          memory: "50Mi"
        requests:
          cpu: 0.1
          memory: "50Mi"
      command: ["/bin/sh",  "-c"]
      args: ["
        echo started;
        trap 'echo SIGTERM received; sleep 10; echo done; exit' SIGTERM;
        while true;
        do
          sleep 2;
        done"]
    - name: long-terminate
      image: "alpine:3.9.5"
      resources:
        limits:
          cpu: 0.1
          memory: "50Mi"
        requests:
          cpu: 0.1
          memory: "50Mi"
      command: ["/bin/sh",  "-c"]
      args: ["
        echo started;
        trap 'echo SIGTERM received, wait 120s; sleep 120; echo done; exit' SIGTERM;
        while true;
        do
          sleep 2;
        done"]

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-14T04:24:29Z", GoVersion:"go1.12.13", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.9-gke.8", GitCommit:"a9973cbb2722793e2ea08d20880633ca61d3e669", GitTreeState:"clean", BuildDate:"2020-02-07T00:50:57Z", GoVersion:"go1.12.12b4", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: GCP managed kubernetes cluster

About this issue

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

Most upvoted comments

/assign

/remove-sig api-machinery /sig node