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

bugfix: clean up the container if the creation fails #2153

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

starnop
Copy link
Contributor

@starnop starnop commented Aug 23, 2018

Signed-off-by: Starnop starnop@163.com

Ⅰ. Describe what this PR did

If the container failed to be created, we should clean up the container.

Ⅱ. Does this pull request fix one issue?

None.

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@pouchrobot pouchrobot added kind/bug This is bug report for project size/S labels Aug 23, 2018
@codecov-io
Copy link

codecov-io commented Aug 23, 2018

Codecov Report

Merging #2153 into master will increase coverage by 0.11%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2153      +/-   ##
==========================================
+ Coverage   64.16%   64.28%   +0.11%     
==========================================
  Files         209      209              
  Lines       16713    16725      +12     
==========================================
+ Hits        10724    10751      +27     
+ Misses       4648     4641       -7     
+ Partials     1341     1333       -8
Flag Coverage Δ
#criv1alpha1test 32.73% <25%> (-0.02%) ⬇️
#criv1alpha2test 33.59% <25%> (+0.23%) ⬆️
#integrationtest 39.23% <0%> (-0.05%) ⬇️
#unittest 23.9% <0%> (-0.02%) ⬇️
Impacted Files Coverage Δ
cri/v1alpha2/cri.go 64.03% <50%> (+0.35%) ⬆️
cri/v1alpha1/cri.go 62.71% <50%> (-0.31%) ⬇️
daemon/mgr/container.go 56.77% <0%> (+0.82%) ⬆️
ctrd/container.go 43.19% <0%> (+1.43%) ⬆️
ctrd/watch.go 80.3% <0%> (+7.57%) ⬆️

@@ -550,6 +550,16 @@ func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateConta

containerID := createResp.ID

defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to put this cleanup in daemon?

Copy link
Contributor Author

@starnop starnop Aug 24, 2018

Choose a reason for hiding this comment

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

It is easier to handle for cri manager, in addition, it also guarantees the atomicity of the function Create in daemon. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think we should put this in container_manager. @Ace-Tang

Copy link
Contributor

Choose a reason for hiding this comment

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

What will daemon do if create container fail? do a container data leaving?

Copy link
Contributor

Choose a reason for hiding this comment

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

@starnop , Yes, I just wonder if we not create through cri interface...

Copy link
Collaborator

Choose a reason for hiding this comment

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

What will daemon do if create container fail? do a container data leaving?

Yeah, just leave it. While for an upper caller, I think if there is an API to provide cleanup action, then call the clean it up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, make sense, still wonder who do this caller if not cri interface.

@allencloud
Copy link
Collaborator

LGTM, while I still would like to invite @fuweid to take a look at this.

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Aug 28, 2018
@@ -502,7 +502,7 @@ func (c *CriManager) ListPodSandbox(ctx context.Context, r *runtime.ListPodSandb
}

// CreateContainer creates a new container in the given PodSandbox.
func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (*runtime.CreateContainerResponse, error) {
func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (_ *runtime.CreateContainerResponse, retErr error) {
Copy link
Contributor

@fuweid fuweid Aug 28, 2018

Choose a reason for hiding this comment

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

could we use var err error to make it readable? because it is hack to use return to assign error to retErr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Signed-off-by: Starnop <starnop@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants