Skip to content

HostPID Pod Container Cgroup path was residual after container restarts #4040

@Burning1020

Description

@Burning1020

Description

We created a HostPID pod that has shared pid namespace with host. The container process was killed and then restarted again and agian. We found that the container cgroup path under /sys/fs/cgroup/<subsystem>/kubepods/podxxx-xxx/<contaienrID>/ was left.

The reason is that runc kill or runc delete did not really wait for the exit of container children process, p.wait() will receive ECHILD immediately, see https://github.com/opencontainers/runc/blob/v1.1.9/libcontainer/init_linux.go#L585C18-L585C18. If any child process is still running, the cgroup path couldn't be removed.

Steps to reproduce the issue

  1. Create a HostPID pod, the container has many children process died and new born.
  2. Kill the main container process for many times.
  3. Container will be restart again by kubelet.

Describe the results you received and expected

Expected: The container cgroup path is deleted.
Received: Still exist.

What version of runc are you using?

runc version 1.1.9
commit: v1.1.9-0-gccaecfcb
spec: 1.0.2-dev
go: go1.20.3
libseccomp: 2.5.4

Host OS information

No response

Host kernel information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions