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: put sandbox into store after created to avoid uncontrolled sandbox container #2326

Merged
merged 1 commit into from
Oct 23, 2018

Conversation

starnop
Copy link
Contributor

@starnop starnop commented Oct 18, 2018

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

Ⅰ. Describe what this PR did

as title described.

Ⅱ. Does this pull request fix one issue?

NONE

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

None.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Cherry pick

@codecov
Copy link

codecov bot commented Oct 18, 2018

Codecov Report

Merging #2326 into master will increase coverage by 1.41%.
The diff coverage is 36.84%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2326      +/-   ##
=========================================
+ Coverage   66.19%   67.6%   +1.41%     
=========================================
  Files         218     218              
  Lines       17674   17678       +4     
=========================================
+ Hits        11699   11951     +252     
+ Misses       4609    4339     -270     
- Partials     1366    1388      +22
Flag Coverage Δ
#criv1alpha1test 32.33% <0%> (+0.02%) ⬆️
#criv1alpha2test 36.19% <26.31%> (?)
#integrationtest 40.45% <0%> (-0.01%) ⬇️
#nodee2etest 33.78% <36.84%> (-0.05%) ⬇️
#unittest 23.41% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
cri/v1alpha2/cri.go 68.76% <36.84%> (+2.58%) ⬆️
cri/ocicni/cni_manager.go 59.18% <0%> (-12.25%) ⬇️
daemon/mgr/snapshot.go 89.85% <0%> (-4.35%) ⬇️
ctrd/container.go 59.28% <0%> (-0.48%) ⬇️
daemon/mgr/container.go 59% <0%> (-0.22%) ⬇️
cri/v1alpha1/cri.go 61.03% <0%> (+0.32%) ⬆️
daemon/containerio/container_io.go 75.95% <0%> (+1.09%) ⬆️
ctrd/client.go 68.25% <0%> (+2.38%) ⬆️
ctrd/watch.go 86.36% <0%> (+3.03%) ⬆️
... and 9 more

@pouchrobot pouchrobot added kind/bug This is bug report for project size/S labels Oct 18, 2018
@starnop starnop force-pushed the pre-store branch 2 times, most recently from d2d1086 to fada42a Compare October 18, 2018 12:16
@@ -270,7 +287,10 @@ func (c *CriManager) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
defer func() {
// If running sandbox failed, clean up the sandbox directory.
if retErr != nil {
os.RemoveAll(sandboxRootDir)
removeErr := os.RemoveAll(sandboxRootDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

use if err := xx; err != nil pattern here?

}
// should not remove the sandbox container metadata from sandboxStore
// until it was removed by pouchd.
removeErr := c.SandboxStore.Remove(id)
Copy link
Contributor

Choose a reason for hiding this comment

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

use if err := xx; err != nil pattern here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it is better to use if err := xx; err != nil, and the err would only take effect in the code block. After that, there is no need to add a new naming removeErr, err is enough.

NetNSPath: netnsPath,
Runtime: config.Annotations[anno.KubernetesRuntime],
}

if _, ok := config.Annotations[anno.LxcfsEnabled]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we put it before create sandbox? I think the validation should be checked at first

Copy link
Contributor

@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.

we should do the validation at the first.

}

// update the metadata of sandbox container after network had been set up successfully.
sandboxMeta.NetNSPath = netnsPath
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this part should be following c.setupPodNetwork. If there is no need to setup Pod network, are we need to update the NetNSPath here?

…ndbox container

Signed-off-by: Starnop <starnop@163.com>
Copy link
Contributor

@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

@fuweid fuweid merged commit 7d423ec into AliyunContainerService:master Oct 23, 2018
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 size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants