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

There is a difference between rshim and goshim when cleaning the task directory #343

Open
fengwei0328 opened this issue Nov 27, 2024 · 0 comments · May be fixed by #342
Open

There is a difference between rshim and goshim when cleaning the task directory #343

fengwei0328 opened this issue Nov 27, 2024 · 0 comments · May be fixed by #342

Comments

@fengwei0328
Copy link

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")
	}

On the go-shim side, for the case of the missing option.json file, no error is returned, the cleanup process continues.
https://github.com/containerd/containerd/blob/f6933cbf0824e6c7f9d126db9e24ab9191c341c7/cmd/containerd-shim-runc-v2/runc/container.go#L175-L181

func ReadOptions(path string) (*options.Options, error) {
	filePath := filepath.Join(path, optionsFilename)
	if _, err := os.Stat(filePath); err != nil {
		if os.IsNotExist(err) {
			return nil, nil
		}
		return nil, err
	}
       //..........
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant