#14257·containerd

Pods stuck Terminating: rootfs umount EBUSY exhausts the 50x50ms retry and never recovers (containerd 2.2.7, GKE/COS)

Author: jitpatel04Created Sep 29, 2026Updated Sep 30, 2026
Labelskind/resource-leak

Description

Containers intermittently fail teardown with failed rootfs umount: ... device or resource busy and never reach Exited, leaving pods stuck Terminating indefinitely. Same signature as #11353 (EKS / AL2 / containerd 1.7.23) and related to #11133 (GKE), both closed without a code fix. Filing fresh because this reproduces on containerd 2.2.7, on a second platform, and because source-level digging has narrowed where the race appears to be.

The sequence, from containerd's own logs:

TaskExit event ... exited_at:{seconds:...}          # process exits cleanly
failed to delete task ... failed rootfs umount: failed to unmount target
  /run/containerd/io.containerd.runtime.v2.task/k8s.io/<id>/rootfs: device or resource busy

Because delete task never succeeds the container never transitions to Exited, so kubelet's StopContainer and StopPodSandbox both time out forever and retry indefinitely. KillPodSandbox failing too is what rules out an application-level cause: nothing in a workload container can make the unrelated pause container unkillable.

It is not workload-specific. We have had six distinct workloads wedged simultaneously across three nodes, one pod sitting Terminating for 5 days 17 hours. On one sampled day we logged over 500 of these EBUSY lines across 3 nodes (a single day's count, not an established average).

This is not the snapshotter

Our container rootfs overlays sit on GKE Image Streaming (gcfs) snapshots, which initially made it look GKE-specific. It isn't — #11353 reproduces the identical signature on EKS / Amazon Linux 2, which has no Image Streaming at all. Stating this explicitly so nobody else spends time there.

Testing the "external process holds a file open" theory — we could not confirm it

In #11353 @samuelkarp suggested a workload that mounts the node root filesystem and holds files open in a container's mount namespace (kubeshark/tracer in his case). We took that seriously:

  • Privileged hostPID probes grepping /proc/*/mountinfo for wedged container IDs, on three specimens across two clusters, including one only 31 minutes after onset.
  • Every time, the only mount namespaces holding the rootfs besides the host were GKE's image_package_extractor and systemd services (udevd, networkd, resolved, chronyd, logind).
  • Neither is selective: image-package-extractor held 95 container rootfs mounts vs the host's 87 — it sees everything, not just wedged ones — and its copy is master:NNNN, a proper slave of the host peer group, so host unmounts propagate to it correctly.
  • Zero submounts beneath any of 85 container rootfs mounts, wedged or healthy. No process held an open fd into the rootfs.
  • Two security/observability agents on these nodes have exactly the capability profile the theory predicts (SYS_ADMIN, SYS_PTRACE, DAC_READ_SEARCH, hostPID). One does not run on a node that wedges repeatedly, falsifying it directly; the other never appeared as a holder on any specimen.

Why all of those probes were meaningless

Reading the source instead of the logs: Delete() in cmd/containerd-shim-runc-v2/process/init.go calls mount.UnmountRecursive(p.Rootfs, 0), and unmount() in core/mount/mount_unix.go is:

go
for range 50 {
    if err := unix.Unmount(target, flags); err != nil {
        switch err {
        case unix.EBUSY:
            time.Sleep(50 * time.Millisecond)
            continue

That is a 2.5 second window, with flags=0 — never MNT_DETACH. Identical in 2.2.7 and current main.

Every probe above ran 31 minutes to 21 hours after the fact, so none of them could ever have observed a transient holder. The "no external holder" result was an unfalsifiable null, not evidence. Worth flagging for anyone else debugging this the same way.

A correctly-timed probe found something

We rebuilt it to tail the host containerd log stream in real time for StopContainer / Killing container on specific already-wedged container IDs, and snapshot /proc/*/mountinfo plus fds the moment one matched. Since kubelet re-enters this path every few minutes for as long as the wedge persists, an already-wedged container gives repeated shots at the 2.5s window rather than one.

Result: on one container's retry we caught a burst of 18 sequential PIDs referencing that container's rootfs mount, all already exited by the time we read their comm and ns/mnt a moment later. Nothing external appeared. Sequential PIDs with sub-second lifetimes fit runc CLI invocations — which go-runc shells out to for kill/delete — far better than any third-party tool. We could not reach exact-PID certainty without eBPF-level tracing.

If that reading is right, this is containerd/runc racing against its own teardown subprocesses, not external interference. That would explain why it is workload-agnostic, why it is intermittent, and why restarting containerd clears it.

Why a wedge never self-heals

shouldCleanupShim in core/runtime/v2/shim_load.go is the only thing that recovers a leaked shim:

go
func shouldCleanupShim(sgetErr, pidErr error, pInfo []runtimeapi.ProcessInfo) bool {
	return errors.Is(sgetErr, errdefs.ErrNotFound) &&
		(errors.Is(pidErr, errdefs.ErrNotFound) ||
			(pidErr == nil && len(pInfo) == 0))
}

It is called only from one-time plugin Init() paths (NewTaskManager, and the sandbox controller) that run at daemon startup. There is no periodic reconciliation, so kubelet can retry for days and nothing is ever able to clear the state.

Restarting containerd on the node does clear it — logs show cleaning leaked shim process, after which kubelet's RemoveContainer succeeds. The underlying unmount / delete task still fails identically; the restart just routes around it via orphan-shim cleanup.

Steps to reproduce the issue

We have no deterministic reproducer; it is a race. What reliably surfaces it is container churn. Our staging cluster runs a Job as an ArgoCD PreSync hook on every sync, so containers are created and exited constantly, and it wedges most days. Our production cluster runs the same images with mostly long-lived Deployments and sees it roughly once a month.

  1. Run a cluster with a high rate of short-lived containers exiting.
  2. Watch containerd logs for failed rootfs umount: ... device or resource busy following a TaskExit for the same container ID.
  3. The corresponding pod stays Terminating indefinitely; crictl shows containerd still retrying the kill hours later.

Describe the results you received and expected

Received: the container process exits cleanly, containerd records TaskExit with a real exited_at, then delete task fails permanently on rootfs umount EBUSY. The container never reaches Exited, the pod never leaves Terminating, and the state persists until the node is recycled or containerd is restarted.

Expected: the container reaches Exited and the pod terminates, or — failing that — containerd is eventually able to recover a shim it has already observed exiting, rather than the state being unrecoverable until daemon restart.

Impact beyond the stuck pod: wedged pods keep holding their scheduler resource requests (we measured 1425m CPU / 4096Mi held across 7 wedged pods, on nodes already at 95% CPU requests), and a wedged pod silently blocks its Deployment's rollout — a new ReplicaSet sits at 0 replicas with no error surfaced anywhere.

What version of containerd are you using?

containerd://2.2.7

Also reported on 1.7.23 in #11353.

Any other relevant information

Kubelet:  v1.35.8-gke.1036000
Runtime:  containerd://2.2.7
OS:       Container-Optimized OS from Google
Kernel:   6.12.94+
Platform: GKE (europe-west1), COS_CONTAINERD node images

Checked and ruled out:

  • No containerd release through v2.4.1 carries a fix for this signature, and no GKE channel (RAPID / REGULAR / STABLE / EXTENDED) ships one.
  • #10721 / #10955 (idmapped mounts under user namespaces) is a red herring for us — we do not use user namespaces.
  • #10589 / #10651 (shim dropping exit notifications) is a genuinely merged fix for a different flavour of stuck-Terminating, and is already in 2.2.7.
  • No DaemonSet on these nodes uses Bidirectional mount propagation into /run/containerd/....

Two questions for maintainers:

  1. Given the retry loop already tolerates EBUSY for 2.5s, is a bounded lazy-unmount fallback (MNT_DETACH once the retries are exhausted) considered viable here? We are aware #10721/#10955 tried a detached unmount in an adjacent snapshotter path and it was reverted over data loss and mount leaks, so this is a question rather than a proposal.
  2. Is there appetite for a guarded periodic shouldCleanupShim sweep? The current check is only safe because at daemon startup nothing can be mid-creation — running it live would need a grace-period or bundle-age guard so a container between "shim spawned" and "first process recorded" is not reaped.

Happy to run further instrumentation; we can reproduce this most days.

Show configuration if it is related to CRI plugin.

Stock GKE COS_CONTAINERD configuration; we do not manage or override the node's containerd config.