Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The task_dir successfully cleans when the file is absent #342

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fengwei0328
Copy link

@fengwei0328 fengwei0328 commented Nov 22, 2024

When containerd is stopped, if the shim process has died and it cannot clean up the task's working directory(WORKPATH=/var/lib/containerd/io.containerd.runtime.v2.task/{NS}/${CID}).
restarting containerd will call cleanupAfterDeadShim to start a shim-delete process to clean up the corresponding bundle remnants.
However, if the $WORKPATH/runtime or $WORKPATH/init.pid` is missing, it will report an error and return directly, resulting in cleanup failure. The error message is as follows:

="failed to clean up after shim disconnected" error="io.containerd.runc.v2-rs: IoError { context: \"failed to open file /run/containerd/io.containerd.runtime.v2.task/k8s.io/c120341d22ebda4fbd7306c6f0e50dc2b7a7a2f11fadf501fd83bdc2dd6ed0a4/runtime\", err: Os { code: 2, kind: NotFound, message: \"No such file or directory\" } }\n: exit status 1" id=c120341d22ebda4fbd7306c6f0e50dc2b7a7a2f11fadf501fd83bdc2dd6ed0a4 namespace=k8s.io

On the go-shim side, for the case of the missing init.pid file, it logs the situation and continues with the cleanup operation, ensuring successful cleanup.

https://github.com/containerd/containerd/blob/f0ebbd3c8a662656b458e7e1cca059a690d557a7/cmd/containerd-shim-runc-v2/manager/manager_linux.go#L318-L321

pid, err := runcC.ReadPidFile(filepath.Join(path, process.InitPidFile))
	if err != nil {
		log.G(ctx).WithError(err).Warn("failed to read init pid file")
	}

@github-actions github-actions bot added the C-runc-shim Runc shim label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-runc-shim Runc shim
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant