kubernetes: GracefulNodeShutdown produces multiple “ContainerStatusUnknown” pods if the node is shut down with pods having not-ready tolerations

What happened?

When having pods that have the following toleration:

      tolerations:
      - key: node.kubernetes.io/not-ready
        operator: Exists

Shutting down the pod’s node configured with GracefulNodeShutdown will leave a number of replicas of the pods in a ContainerStatusUnknown status after restarting the node where the pod originally was.

# kubectl get no,po -o wide
NAME                             STATUS   ROLES           AGE   VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE          KERNEL-VERSION                CONTAINER-RUNTIME
node/localhost.localdomain       Ready    control-plane   13h   v1.32.2   192.168.100.110   <none>        CentOS Stream 8   5.4.290-1.el8.elrepo.x86_64   containerd://1.6.32
node/localmachine2.localdomain   Ready    <none>          13h   v1.32.2   192.168.100.111   <none>        CentOS Stream 8   5.4.290-1.el8.elrepo.x86_64   containerd://1.6.32

NAME                           READY   STATUS                   RESTARTS   AGE     IP            NODE                        NOMINATED NODE   READINESS GATES
pod/testpod-558577cfcb-26ztn   0/1     ContainerStatusUnknown   0          6m6s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-7wqjj   0/1     ContainerStatusUnknown   0          6m5s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-lj8j9   0/1     ContainerStatusUnknown   0          6m5s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-mjn6n   0/1     ContainerStatusUnknown   0          6m6s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-mtck6   0/1     ContainerStatusUnknown   0          6m6s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-qnltn   0/1     Error                    0          6m22s   <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-qpnvb   0/1     ContainerStatusUnknown   0          6m7s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-tflc8   1/1     Running                  0          6m4s    10.244.1.35   localmachine2.localdomain   <none>           <none>

According to kubectl get po -w:

NAME                       READY   STATUS    RESTARTS   AGE
testpod-558577cfcb-qnltn   1/1     Running   0          6s
<-- Node is shutdown -->
testpod-558577cfcb-qnltn   0/1     Error     0          15s
testpod-558577cfcb-qpnvb   0/1     Pending   0          0s
testpod-558577cfcb-qpnvb   0/1     Pending   0          1s
testpod-558577cfcb-qpnvb   0/1     NodeShutdown   0          1s
testpod-558577cfcb-mtck6   0/1     Pending        0          0s
testpod-558577cfcb-mtck6   0/1     Pending        0          0s
testpod-558577cfcb-mtck6   0/1     NodeShutdown   0          0s
testpod-558577cfcb-mjn6n   0/1     Pending        0          0s
testpod-558577cfcb-mjn6n   0/1     Pending        0          0s
testpod-558577cfcb-mjn6n   0/1     NodeShutdown   0          0s
testpod-558577cfcb-26ztn   0/1     Pending        0          0s
testpod-558577cfcb-26ztn   0/1     Pending        0          0s
testpod-558577cfcb-26ztn   0/1     NodeShutdown   0          1s
testpod-558577cfcb-lj8j9   0/1     Pending        0          0s
testpod-558577cfcb-lj8j9   0/1     Pending        0          0s
testpod-558577cfcb-lj8j9   0/1     NodeShutdown   0          0s
testpod-558577cfcb-7wqjj   0/1     Pending        0          0s
testpod-558577cfcb-7wqjj   0/1     Pending        0          0s
testpod-558577cfcb-7wqjj   0/1     NodeShutdown   0          1s
testpod-558577cfcb-tflc8   0/1     Pending        0          0s
testpod-558577cfcb-tflc8   0/1     Pending        0          0s
<-- Node is booted up -->
testpod-558577cfcb-7wqjj   0/1     ContainerCreating   0          112s
testpod-558577cfcb-lj8j9   0/1     ContainerCreating   0          112s
testpod-558577cfcb-tflc8   0/1     ContainerCreating   0          111s
testpod-558577cfcb-qnltn   0/1     Error               0          2m9s
testpod-558577cfcb-mjn6n   0/1     ContainerCreating   0          113s
testpod-558577cfcb-qpnvb   0/1     ContainerCreating   0          115s
testpod-558577cfcb-mtck6   0/1     ContainerCreating   0          114s
testpod-558577cfcb-26ztn   0/1     ContainerCreating   0          114s
testpod-558577cfcb-qpnvb   0/1     ContainerStatusUnknown   0          116s
testpod-558577cfcb-mtck6   0/1     ContainerStatusUnknown   0          115s
testpod-558577cfcb-26ztn   0/1     ContainerStatusUnknown   0          115s
testpod-558577cfcb-mjn6n   0/1     ContainerStatusUnknown   0          115s
testpod-558577cfcb-7wqjj   0/1     ContainerStatusUnknown   0          115s
testpod-558577cfcb-lj8j9   0/1     ContainerStatusUnknown   0          115s
testpod-558577cfcb-tflc8   1/1     Running                  0          2m12s

What did you expect to happen?

I was expecting that there will be no pods with ContainerStatusUnknown.

How can we reproduce it (as minimally and precisely as possible)?

Minimal Env: 1 Cluster with 1 control plane and 1 worker node

Reproduction:

  1. Enable GracefulNodeShutdown feature in your node.
featureGates:
  GracefulNodeShutdown: true
shutdownGracePeriod: 90s
shutdownGracePeriodCriticalPods: 30s
  1. Create the following Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: testpod
  namespace: default
  labels:
    app: testpod
spec:
  replicas: 1
  selector:
    matchLabels:
      app: testpod
  template:
    metadata:
      labels:
        app: testpod
    spec:
      containers:
      - name: busybox
        image:  busybox
        command:  ["/bin/sh", "-c"]
        args:
        - |
          trap "trap - TERM; kill 0; exit" TERM; sleep 1000000 & wait
      terminationGracePeriodSeconds: 30
      tolerations:
      - key: node.kubernetes.io/not-ready
        operator: Exists
  1. Create the deployment
# kubectl create -f testpod.yaml
deployment.apps/testpod created

# kubectl get no,po -o wide
NAME                             STATUS   ROLES           AGE   VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE          KERNEL-VERSION                CONTAINER-RUNTIME
node/localhost.localdomain       Ready    control-plane   13h   v1.32.2   192.168.100.110   <none>        CentOS Stream 8   5.4.290-1.el8.elrepo.x86_64   containerd://1.6.32
node/localmachine2.localdomain   Ready    <none>          13h   v1.32.2   192.168.100.111   <none>        CentOS Stream 8   5.4.290-1.el8.elrepo.x86_64   containerd://1.6.32

NAME                          READY   STATUS    RESTARTS   AGE   IP            NODE                        NOMINATED NODE   READINESS GATES
pod/testpod-774dc69db-8ttnq   1/1     Running   0          32s   10.244.1.33   localmachine2.localdomain   <none>           <none>
  1. Reboot the worker node (in this example, localmachine2.localdomain)
[user@localmachine2 ~] sudo systemctl reboot
  1. Wait for a few minutes until the node shuts down and starts up again.
  2. Check the pod list
# kubectl get no,po -o wide
NAME                             STATUS   ROLES           AGE   VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE          KERNEL-VERSION                CONTAINER-RUNTIME
node/localhost.localdomain       Ready    control-plane   13h   v1.32.2   192.168.100.110   <none>        CentOS Stream 8   5.4.290-1.el8.elrepo.x86_64   containerd://1.6.32
node/localmachine2.localdomain   Ready    <none>          13h   v1.32.2   192.168.100.111   <none>        CentOS Stream 8   5.4.290-1.el8.elrepo.x86_64   containerd://1.6.32

NAME                           READY   STATUS                   RESTARTS   AGE     IP            NODE                        NOMINATED NODE   READINESS GATES
pod/testpod-558577cfcb-26ztn   0/1     ContainerStatusUnknown   0          6m6s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-7wqjj   0/1     ContainerStatusUnknown   0          6m5s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-lj8j9   0/1     ContainerStatusUnknown   0          6m5s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-mjn6n   0/1     ContainerStatusUnknown   0          6m6s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-mtck6   0/1     ContainerStatusUnknown   0          6m6s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-qnltn   0/1     Error                    0          6m22s   <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-qpnvb   0/1     ContainerStatusUnknown   0          6m7s    <none>        localmachine2.localdomain   <none>           <none>
pod/testpod-558577cfcb-tflc8   1/1     Running                  0          6m4s    10.244.1.35   localmachine2.localdomain   <none>           <none>

Anything else we need to know?

No response

Kubernetes version

# kubectl version
Client Version: v1.32.2
Kustomize Version: v5.5.0
Server Version: v1.32.2

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
$ uname -a
Linux localhost.localdomain 5.4.290-1.el8.elrepo.x86_64 #1 SMP Sat Feb 1 18:53:57 EST 2025 x86_64 x86_64 x86_64 GNU/Linux

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I tried replicating this issue on minikube cluster with the same step provided in the issue to replicate the issue but it is not giving me the list of the pod after restarting it only give the running list When i stop the workernode and before restarting the worker node then only i get the status as error but after restarting the worker node the pods is working fine and is in running state. without any containerunknown status pod.

I found the same error in my minikube cluster as well. This issue arises in both kubeadm and minikube clusters.

After checking the configuration again, I found the same error in my minikube cluster as well. This issue arises in both kubeadm and minikube clusters.

@SergeyKanzhelev confirmed!

Talos enables Graceful Node Shutdown by default. Turning it off stops kubernetes from trying to schedule an endless amount of pods during shutdown.

I’m also seeing some Pods enter the Error and Completed state.

I just checked, however, that after leaving the node in a power off state for a considerable length, about 5 minutes, and powering on again does not produce the ContainerStatusUnknown same pods.

This one I can’t reproduce. I left a control-plane node off for 8-9 minutes just to be sure, but the pods still changed from NodeShutdown to ContainerStatusUnknown when I started the node again. Perhaps there is some other Talos default config that affects this.

I can confirm that I am seeing the same thing. Running Talos 1.9 with Kubernetes 1.32.0. The pod status changes from “NodeShutdown” to “ContainerStatusUnknown” once the node has restarted.

Image

This is my current cleanup procedure:

kubectl -n kube-system get pod -ojson | jq -r '.items[] | select([.status | .containerStatuses[] | .state.terminated.reason == "ContainerStatusUnknown"] | any) | .metadata.name' | xargs -n1 kubectl -n kube-system delete pod

In fact. I’m also seeing containers end up in the “Completed” state when restarting worker nodes.