k0s reset leaves containerd shim state under the shared /run/containerd, breaking same-ID container creation after reinstall
What happened?
The shims of k0s's managed containerd keep their runtime state under the host-shared /run/containerd, not under k0s's own run dir: with a single-node cluster running, a container's runc state is at /run/containerd/runc/k8s.io/<id> and its IO fifos under /run/containerd/fifo/<n>/. k0s reset cleans /run/k0s, the data dir and the kubelet root dir, but never /run/containerd — understandably, since that path can be shared with a host containerd or Docker and cannot be deleted blindly.
Container state created outside the CRI plugin (e.g. via ctr/nerdctl in the k8s.io namespace, or a leftover shim) is not cleaned by the CRI-based containers step, so it survives a successful reset. After reset + reinstall on the same booted host, recreating a container with the same ID then fails:
Error: failed to create shim task: OCI runtime create failed: runc create failed: container with given ID already existsA reboot clears it (/run is tmpfs), matching reset's "a node reboot is recommended" hint — but automated stop → reset → reinstall flows that do not reboot hit this.
Steps to reproduce (released v1.36.3+k0s.0, verified on a fresh Ubuntu 22.04 EC2 instance)
k0s install controller --single && k0s start # wait Ready
k0s ctr -n k8s.io run -d docker.io/library/busybox:1.36 samename sleep 100000
# /run/containerd/runc/k8s.io/samename now exists (shared path, not under /run/k0s)
k0s stop
# release the task mount by hand so reset does not fail on #8048:
umount /run/k0s/containerd/io.containerd.runtime.v2.task/k8s.io/samename/rootfs
k0s reset --data-dir /var/lib/k0s --kubelet-root-dir /var/lib/kubelet # succeeds (rc=0)
# /run/containerd/runc/k8s.io/samename and a /run/containerd/fifo/* dir remain
k0s install controller --single && k0s start
k0s ctr -n k8s.io run -d docker.io/library/busybox:1.36 samename sleep 100000
# -> Error: ... container with given ID already existsVerified outcome: reset exits 0, the same-ID create exits 1 with the error above; k0s's own directories (/run/k0s, /var/lib/k0s) were removed while /run/containerd/runc/k8s.io/samename persisted.
Expected behavior
Shim state for k0s's containerd lives under a k0s-owned path (e.g. below the run dir), so the existing reset cleanup covers it — rather than reset having to delete from a path shared with other container runtimes.
Notes
Found while fixing #8048 (whose leftover mount comes from the same non-CRI container mechanism). This is a distinct, narrower problem: it persists after a successful reset, independent of that fix.
Version
v1.36.3+k0s.0Platform
Ubuntu 22.04.5 LTS, kernel 6.8, x86_64, AWS EC2, single nodeSource: k0sproject/k0s