Skip to content

containerd-shim: CmdDel blocks indefinitely on unavailable CNI socket causing ttrpc leak and persistent kubelet DeadlineExceeded #13326

Closed

Description

@lpoclin

Description

What happened

An unplanned power outage caused an abrupt shutdown of all 4 nodes simultaneously. On power restoration, containerd restarted on every node before the CNI plugins multus and flannel were ready.

On startup, containerd reconnected to orphan shims from pre-outage DaemonSet sandbox containers and those shims immediately attempted CmdDel cleanup against /run/multus/multus.sock, which did not exist yet. The CmdDel call appears to block indefinitely with no observable timeout. All shims entered futex_wait_queue and remained blocked. containerd kept ttrpc connections open to these blocked shims without apparent recovery or garbage collection, resulting in persistent DeadlineExceeded on kubelet CRI calls on every node for 25 days until manual intervention.

The control plane node was recovered first but without captured forensic output due to terminal session loss. Full evidence was captured on the 3 worker nodes which remained in the blocked state at the time of documentation. Given that all nodes run the same containerd version and CNI stack and experienced the same outage conditions, the behavior is expected to be identical across all 4.

Image

What I expected

A timeout error and clean failure, or containerd detecting stuck shims and recovering automatically. Instead the shims blocked indefinitely with no recovery path and no indication in the logs that the state was unrecoverable.

Confirmed evidence — 3 independent worker nodes

wchan — indefinite kernel wait on all 4 shims per node

for pid in $(sudo pgrep -f containerd-shim); do
  wchan=$(sudo cat /proc/$pid/wchan 2>/dev/null)
  [ -n "$wchan" ] && echo "PID $pid: $wchan"
done
# k8s-w-5gccp
PID 1145: futex_wait_queue
PID 1147: futex_wait_queue
PID 1172: futex_wait_queue
PID 1208: futex_wait_queue
 
# k8s-w-5gcup
PID 1135: futex_wait_queue_me
PID 1195: futex_wait_queue_me
PID 1219: futex_wait_queue_me
PID 1229: futex_wait_queue_me
 
# k8s-w-obs
PID 1188: futex_wait_queue
PID 1190: futex_wait_queue
PID 1237: futex_wait_queue
PID 1264: futex_wait_queue
Image Image Image

4 ttrpc connections never closed (per node)

sudo ss -xp | grep containerd.sock.ttrpc
u_str ESTAB /run/containerd/containerd.sock.ttrpc users:(("containerd",pid=707,fd=34))
u_str ESTAB /run/containerd/containerd.sock.ttrpc users:(("containerd",pid=707,fd=35))
u_str ESTAB /run/containerd/containerd.sock.ttrpc users:(("containerd",pid=707,fd=49))
u_str ESTAB /run/containerd/containerd.sock.ttrpc users:(("containerd",pid=707,fd=50))
Image Image Image

crictl DeadlineExceeded on every call

time sudo crictl --runtime-endpoint unix:///run/containerd/containerd.sock info
FATA[0002] getting status of runtime: rpc error: code = DeadlineExceeded
real    0m2.012s
Image Image Image

Consistent across all 3 nodes.

Critical log — CmdDel race window confirmed at millisecond precision

10:36:13.119Z  containerd connects to 4 orphan shims via ttrpc
10:36:13Z      [error] CmdDel (shim): dial unix /run/multus/multus.sock:
               connect: no such file or directory  [x10]
10:36:13.192Z  install-multus-binary container created  ← 73ms after CmdDel
10:36:14.826Z  kube-flannel container created           ← 1.7s after CmdDel
Image Image

The shims attempted cleanup before the CNI containers existed.
The socket became available too late — the shims were already blocked.

Orphan sandbox identity — same 4 DaemonSets on every node

for id in $(sudo pgrep -af containerd-shim | grep -oP '\-id \K[a-f0-9]+'); do
  sudo ctr -n k8s.io containers info $id 2>/dev/null | \
    grep -E 'pod.name|pod.namespace|cri-containerd.kind'
done
Image

Same result on all 3 nodes — all standard Kubernetes infrastructure
DaemonSets, no specialized workloads involved:
kube-proxy, prometheus-node-exporter, kube-multus-ds, kube-flannel-ds

Cross-node summary

Node Containerd PID wchan ttrpc blocked Orphan sandboxes
k8s-w-5gccp 707 futex_wait_queue 4 kube-proxy, node-exporter, kube-multus-ds, kube-flannel-ds
k8s-w-5gcup 753 futex_wait_queue_me 4 kube-proxy, node-exporter, kube-multus-ds, kube-flannel-ds
k8s-w-obs 706 futex_wait_queue 4 kube-proxy, node-exporter, kube-multus-ds, kube-flannel-ds

futex_wait_queue and futex_wait_queue_me reflect different moments
of the same kernel wait path — entry and sustained steady-state.

Potentially relevant code path (hypothesis)

internal/cri/server/sandbox_stop.go — teardownPodNetwork:

err = netPlugin.Remove(ctx, id, path, opts...)

If ctx has no deadline during shim reconnection at startup, this call may block indefinitely when the CNI socket is unavailable. This is a hypothesis based on observed behavior — not verified at the code level. Happy to be corrected on this.

Introspection attempt

Goroutine-level inspection was attempted but pprof was not available
in this production binary:

sudo nsenter -t 707 -n curl -v http://localhost:35169/debug/pprof/goroutine?debug=2
# HTTP/1.1 404 Not Found — no pprof handlers registered

Image

The presumed goroutine retention in containerd's event loop is inferred from observed behavior and Go's M:N scheduler model. Direct confirmation was not possible without recompiling with debug flags.

Workaround applied

# /etc/systemd/system/containerd.service under [Service]
ExecStartPost=/bin/sh -c 'until [ -S /run/multus/multus.sock ] && \
  [ -f /run/flannel/subnet.env ]; do sleep 1; done'

Related commit

Commit 0b84719 ("fix issue where cni del is never executed", merged in v2.3.0-rc.1) addresses a related but distinct case where CNIResult is nil and teardown is skipped. The scenario here occurs when CNIResult is present and teardown is attempted but the call blocks indefinitely on an unavailable socket. Both affect the same code path but appear to be different failure modes — happy to be corrected if I'm wrong about this distinction.

Questions for maintainers

  1. Should netPlugin.Remove in teardownPodNetwork enforce a
    bounded timeout to prevent indefinite blocking on unavailable
    CNI sockets?
  2. Should containerd detect shims stuck in blocking syscalls at
    startup and force-terminate them rather than keeping ttrpc
    connections open indefinitely?
  3. Is there an existing recovery mechanism for this scenario that
    I may have missed in this deployment?

Full forensic report and log artifacts

https://github.com/lpoclin/casebook/tree/main/incidents/INC-2026-002-containerd-runtime-failure

Steps to reproduce the issue

  1. Kubernetes cluster with Flannel + Multus as meta-CNI
  2. Force abrupt power loss on all nodes (no graceful drain)
  3. Power on — containerd restarts before CNI plugins initialize
  4. Orphan shims from pre-outage DaemonSet sandboxes attempt CmdDel
    against /run/multus/multus.sock which does not exist yet
  5. Shims enter futex_wait_queue indefinitely, containerd gRPC becomes
    unresponsive to kubelet

Describe the results you received and expected

Received: shims blocked indefinitely in futex_wait_queue, 4 ttrpc
connections never closed, kubelet DeadlineExceeded on every CRI call
for 25 days.

Expected: timeout error and clean failure, or automatic detection and
recovery of stuck shims.

What version of containerd are you using?

v2.0.1 (commit: 88aa2f5)

Any other relevant information

runc:

runc version 1.2.3
commit: v1.2.3-0-g0d37cfd4
spec: 1.2.0
go: go1.22.10
libseccomp: 2.5.5

uname -a:

Linux k8s-w-5gccp 6.8.0-106-generic #106-Ubuntu SMP x86_64 GNU/Linux

Full forensic report and log artifacts:
https://github.com/lpoclin/casebook/tree/main/incidents/INC-2026-002-containerd-runtime-failure

Show configuration if it is related to CRI plugin.

Standard containerd CRI config, no custom modifications.
CNI: /etc/cni/net.d/ — multus-shim as primary entry point,
flannel as clusterNetwork for eth0.

Activity

  1. added
    area/cri
    on Apr 30, 2026
  2. MikeZappa87 commented on Apr 30, 2026

    @MikeZappa87
    Member

    Did Multus and flannel ever come up? I can't tell if those pods didn't come up or something was blocking them from coming up as those are responsible for cleaning up with the CNI DEL.

  3. samuelkarp commented on Apr 30, 2026

    @samuelkarp
    Member

    Please don't dump giant walls of LLM output into issues without reading them critically.

    On startup, containerd reconnected to orphan shims from pre-outage DaemonSet sandbox containers

    If there was a power loss, there would be no existing running shims to connect to.

    v2.0.1

    This version of containerd was released in December, 2024. It is very old. The latest patch version on the 2.0 branch is 2.0.8. Additionally, 2.0 has entered a more limited support phase focused on use-cases with GKE. GKE does not use multus or flannel. I would recommend upgrading to a current supported version of containerd such as 2.2.3.

  4. lpoclin commented on Apr 30, 2026

    @lpoclin
    Author

    Correct, "reconnected" was inaccuarate on my part. I will upgrade to 2.2.3 and test whether the behavior persists.

  5. lpoclin commented on Apr 30, 2026

    @lpoclin
    Author

    @MikeZappa87 Yes, Multus and Flannel came up successfully, the issue was that containerd spawned new shims to handle orphaned containers, and those shims attempted CmdDel before the multus socket was available. Once the socket became available the shims were already blocked in futex_wait_queue and never retried cleanup.

  6. MikeZappa87 commented on Apr 30, 2026

    @MikeZappa87
    Member

    Should this be closed? It looks like everything worked as intended?

  7. samuelkarp commented on Apr 30, 2026

    @samuelkarp
    Member

    and those shims attempted CmdDel before the multus socket was available.

    Shims don't call CNI DEL. The containerd daemon calls the CNI plugin.

  8. ningmingxiao commented on May 2, 2026

    @ningmingxiao
    Contributor

    can you kill -10 pidof containerd (save stack at /tmp/ )and kill -10 shimpid (print stack into containerd log) may print the stack we can see whereis hanging @lpoclin

  9. lpoclin commented on May 2, 2026

    @lpoclin
    Author

    @ningmingxiao Unfortunately I had to recover the cluster due to urgency, but I’ll upgrade to v2.2.3 and try to reproduce the issue and share any findings.

  10. lpoclin commented on May 6, 2026

    @lpoclin
    Author

    Reproduced the outage scenario on v2.2.3 (commit 77c8424).
    On restart, containerd logs "Start recovering state" and successfully completes "TearDown" for orphaned sandboxes, gRPC ok and ttrpc connections are properly cleaned up on restart
    Closing.

    Logs (v2.2.3):

    May 06 10:56:09 k8s-ctl containerd[644]: time="2026-05-06T10:56:09.118875661Z" level=info msg="Start recovering state"
    May 06 10:56:19 k8s-ctl containerd[644]: time="2026-05-06T10:56:19.384693790Z" level=info msg="StopPodSandbox for \"45ca3a0ccec038a95c11c1a707f5bc07d4305473223ba9c917bf6fb0df23746b\""
    May 06 10:56:19 k8s-ctl containerd[644]: time="2026-05-06T10:56:19.385013940Z" level=info msg="TearDown network for sandbox \"45ca3a0ccec038a95c11c1a707f5bc07d4305473223ba9c917bf6fb0df23746b\" successfully"
    ...
    
    Image
  11. ThePlenkov commented on Jul 25, 2026

    @ThePlenkov

    Related: containerd-shim zombie state on Docker Desktop / WSL2 — different trigger, same symptom

    Not a CNI issue, but same core problem: shims block indefinitely on futex_wait_queue with no recovery path, causing all Docker API calls to those containers to hang forever.

    Environment

    Component Version
    Docker Desktop 4.83.0 (234302)
    Docker Engine 29.6.2
    containerd v2.2.5 (e53c7c1)
    runc 1.3.6
    Kernel 6.18.33.2-microsoft-standard-WSL2
    Platform Windows 11 + WSL2

    What happened

    4 LiteLLM containers (separate compose projects, shared Postgres/Redis) entered a state where:

    1. The container application processes (Python/uvicorn) exited silently (likely OOM or resource exhaustion — high swap usage 10Gi/12Gi at incident time)
    2. Their containerd-shim-runc-v2 processes remained alive in S (sleeping) state on futex_do_wait
    3. All 4 shims had zero child processes (verified via /proc/$pid/task/*/children)
    4. Docker daemon considered the containers "running" — docker ps showed running (unhealthy)
    5. Every API call to these containers blocked indefinitely: stop, kill, rm -f, inspect, logs, top, stats
    6. docker stats showed -- / -- for resource usage (daemon couldn't read cgroup metrics)
    7. Non-affected containers on the same daemon responded normally

    Evidence from inside Docker Desktop VM

    # Accessed via: docker run --rm --pid=host --privileged alpine
    
    # 4 shims alive with zero children
    for pid in 1842 1929 2016 2103; do
      children=$(cat /proc/$pid/task/*/children 2>/dev/null)
      state=$(cat /proc/$pid/status | grep State)
      wchan=$(cat /proc/$pid/wchan 2>/dev/null)
      echo "PID $pid: children=[${children:-NONE}] $state wchan=$wchan"
    done
    # PID 1842: children=[NONE] State: S (sleeping) wchan=futex_wait_queue
    # PID 1929: children=[NONE] State: S (sleeping) wchan=futex_wait_queue
    # PID 2016: children=[NONE] State: S (sleeping) wchan=futex_wait_queue
    # PID 2103: children=[NONE] State: S (sleeping) wchan=futex_wait_queue

    Timeline from Docker Desktop backend logs

    Time Event
    14:54:46 All 4 containers healthy (port-forwarding active)
    14:57:06 compose/v5.3.1 stops 2 non-litellm containers — completes in 4 sec
    14:57:11 compose/v5.3.1 sends POST /stop to container v2 — no response ever
    15:04:15 POST /stop to container v3 — no response
    15:08:07 POST /kill?signal=KILL to container v2 — no response
    15:09:10 Docker Desktop compose timeout after 5 minutes, exit status 1
    15:17:51 POST /stop to container v5 — no response

    The containers became zombies before any stop/kill attempt — the stop at 14:57:11 hung immediately, meaning the shims were already in degenerate state.

    How this differs from #13326

    • Trigger: not CNI socket unavailability, but container PID 1 death (process crash/OOM) leaving the shim with zero children
    • No CmdDel involved: the shim simply never noticed its child exited
    • Same outcome: shim blocked on futex, daemon blocked on API calls to that container, no automatic recovery

    Resolution

    Only kill -9 on the zombie shim PIDs from inside the VM resolved it. The daemon then reconciled the container state (marked Exited (255)) and normal operations resumed.

    Suggested improvement

    The shim should detect when its child process set becomes empty and emit a task-exit event rather than blocking indefinitely. Alternatively, the daemon could implement a watchdog that periodically checks if running shims still have live children, and force-reconciles if they don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/criarea/runtimekind/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions