Skip to content

runtime-v1: kill shim in exit handler#3226

Merged
dmcgowan merged 1 commit intocontainerd:masterfrom
Ace-Tang:kill_shim_in_clean
May 22, 2019
Merged

runtime-v1: kill shim in exit handler#3226
dmcgowan merged 1 commit intocontainerd:masterfrom
Ace-Tang:kill_shim_in_clean

Conversation

@Ace-Tang
Copy link
Copy Markdown
Contributor

The patch do two things,

  1. refactor cleanupAfterDeadShim function, judge if task is available, if
    has, do cleanup.

  2. add kill shim in cleanupDeadShim, in cleanup , r.tasks.Delete(ctx, id) will be called, then the task should be removed from task list, so do more killShim function, make less leak shim.

Signed-off-by: Ace-Tang aceapril@126.com

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.

We shouldn't do this in loadTasks, because task is not added to the task list yet, this will always return.

That's why this is kept out side of cleanupAfterDeadShim before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I also aware this, and restore the code.

@Ace-Tang Ace-Tang force-pushed the kill_shim_in_clean branch from 0a55186 to f3a8615 Compare April 18, 2019 07:16
@Ace-Tang Ace-Tang changed the title runtime-v1: kill shim in cleanupDeadShim runtime-v1: kill shim in exit handler Apr 18, 2019
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.

The exitHandler will only be called when the shim process exits, there is no need to kill it again.

I do agree that the cleanupAfterDeadShim onClose function installed by loadTasks may try killing the shim. But please not that for shim v2 we can no longer do that, because shim v2 implementation may have per-pod shim process, which can't be killed when one container dies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I get some time to check the code, and try to explain my logic:

  1. in exit handler, the normal case should be shim exit and resources be cleanup, but in bad case, still some shim hangover. so I want to add one more kill to shim
  2. in loadTasks, I do not found the good place to do killShim, we get shimclient through bundle.NewShimClient, but if not get response, we can not do KillShim

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also aware in loadTasks t.tasks is empty, so we do not need check task available here ? @Random-Liu

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 is called later on close, so we still need to check this.

The error handling below doesn't need to check, because the task is not in list yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, I miss the point

@Ace-Tang Ace-Tang force-pushed the kill_shim_in_clean branch from f3a8615 to 33e35df Compare April 18, 2019 08:12
@estesp
Copy link
Copy Markdown
Member

estesp commented Apr 18, 2019

Please rebase on master to pick up the fix for AppVeyor CI

@Ace-Tang
Copy link
Copy Markdown
Contributor Author

It can be log the shim pid in bundle and kill shim in cleanDeadShim

1. kill shim in cleanupAfterDeadShim avoid shim leak
2. refactor cleanupAfterDeadShim, get pid from bundle
path instead of make pid as a parameter

Signed-off-by: Ace-Tang <aceapril@126.com>
@Ace-Tang Ace-Tang force-pushed the kill_shim_in_clean branch from 33e35df to dfa51c9 Compare April 22, 2019 06:30
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #3226 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3226   +/-   ##
=======================================
  Coverage   44.63%   44.63%           
=======================================
  Files         113      113           
  Lines       12161    12161           
=======================================
  Hits         5428     5428           
  Misses       5898     5898           
  Partials      835      835
Flag Coverage Δ
#linux 48.65% <ø> (ø) ⬆️
#windows 39.86% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 835e6d0...dfa51c9. Read the comment docs.

@dmcgowan dmcgowan requested a review from crosbymichael May 6, 2019 22:47
@crosbymichael
Copy link
Copy Markdown
Member

LGTM

1 similar comment
@dmcgowan
Copy link
Copy Markdown
Member

LGTM

@dmcgowan dmcgowan merged commit c9c555c into containerd:master May 22, 2019
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 this pull request may close these issues.

6 participants