Skip to content

containerd-shim-runc-v2: return init pid when clean dead shim#6452

Merged
fuweid merged 1 commit intocontainerd:mainfrom
zvier:main
Feb 17, 2022
Merged

containerd-shim-runc-v2: return init pid when clean dead shim#6452
fuweid merged 1 commit intocontainerd:mainfrom
zvier:main

Conversation

@zvier
Copy link
Copy Markdown
Contributor

@zvier zvier commented Jan 18, 2022

If containerd-shim-runc-v2 process dead abnormally, such as received
kill -s 9 signal, panic or other unkown reasons, the containerd-shim-runc-v2
server can not reap runc container and forward init process exit event.
This will lead the container leaked in dockerd. When shim dead, containerd
will clean dead shim, here read init process pid and forward exit event
with pid at the same time.

Signed-off-by: Jeff Zvier zvier20@gmail.com

@k8s-ci-robot
Copy link
Copy Markdown

Hi @zvier. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@zvier
Copy link
Copy Markdown
Contributor Author

zvier commented Jan 18, 2022

related #6402

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Jan 18, 2022

Build succeeded.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Jan 20, 2022

Build succeeded.

If containerd-shim-runc-v2 process dead abnormally, such as received
kill 9 signal, panic or other unkown reasons, the containerd-shim-runc-v2
server can not reap runc container and forward init process exit event.
This will lead the container leaked in dockerd. When shim dead, containerd
will clean dead shim, here read init process pid and forward exit event
with pid at the same time.

Signed-off-by: Jeff Zvier <zvier20@gmail.com>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Jan 20, 2022

Build succeeded.

@zvier
Copy link
Copy Markdown
Contributor Author

zvier commented Jan 24, 2022

@kzys Hello, I had improved this PR last week, can you take a look again ?

Comment on lines +274 to +276
if err != nil {
log.G(ctx).WithError(err).Warn("failed to read init pid file")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about returning this error instead of logging? The function should return either a valid value or error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used to cleanup the resource, which is handled in command-line.
It should not return error here.

@zvier
Copy link
Copy Markdown
Contributor Author

zvier commented Feb 9, 2022

@kzys Hello, please review this PR agagin ?

@fuweid fuweid self-assigned this Feb 9, 2022
@fuweid fuweid modified the milestone: 1.6 Feb 9, 2022
Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on Green.


Tested in my local

# Terminal 1
2022-02-09 14:59:07.994652691 +0000 UTC moby /tasks/exit {"container_id":"8857863cb748d2835781232a7d99e5ba4c0c497f6210513490b4add719993680","id":"8857863cb748d2835781232a7d99e5ba4c0c497f6210513490b4add719993680","pid":206640,"exit_status":137,"exited_at":"2022-02-09T14:59:07.993201143Z"}
2022-02-09 14:59:07.994680201 +0000 UTC moby /tasks/delete {"container_id":"8857863cb748d2835781232a7d99e5ba4c0c497f6210513490b4add719993680","pid":206640,"exit_status":137,"exited_at":"2022-02-09T14:59:07.993201143Z"}
2022-02-09 14:59:08.186136836 +0000 UTC moby /containers/delete {"id":"8857863cb748d2835781232a7d99e5ba4c0c497f6210513490b4add719993680"}

# Terminal 2
➜  containerd git:(review-6452) docker run -d busybox sleep 1d
8857863cb748d2835781232a7d99e5ba4c0c497f6210513490b4add719993680
➜  containerd git:(review-6452) ps -ef | grep sleep
root      206640  206619  0 22:58 ?        00:00:00 sleep 1d
chaofan   206700  152304  0 22:59 pts/0    00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox sleep
➜  containerd git:(review-6452) sudo pkill -9 containerd-shim
➜  containerd git:(review-6452) docker ps -a | grep 88578
8857863cb748   busybox        "sleep 1d"               2 minutes ago       Exited (137) About a minute ago             relaxed_leakey

@kzys
Copy link
Copy Markdown
Member

kzys commented Feb 10, 2022

/ok-to-test

@zvier
Copy link
Copy Markdown
Contributor Author

zvier commented Feb 16, 2022

@dmcgowan Hello,can you review this PR ?

@estesp
Copy link
Copy Markdown
Member

estesp commented Feb 16, 2022

/retest

@fuweid fuweid merged commit 3122239 into containerd:main Feb 17, 2022
@fuweid fuweid added cherry-picked/1.5.x PR commits are cherry-picked into release/1.5 branch cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch and removed cherry-pick/1.5.x labels Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/1.5.x PR commits are cherry-picked into release/1.5 branch cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants