-
Notifications
You must be signed in to change notification settings - Fork 949
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: fix that ContainerManager.Create wouldn't remove snapshot when failed #2080
bugfix: fix that ContainerManager.Create wouldn't remove snapshot when failed #2080
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2080 +/- ##
===========================================
+ Coverage 39.41% 64.97% +25.56%
===========================================
Files 212 209 -3
Lines 16462 16239 -223
===========================================
+ Hits 6488 10551 +4063
+ Misses 8955 4375 -4580
- Partials 1019 1313 +294
|
Thanks a lot for your contribution. Just double check could we add an integration test for this case? @xiaoxubeii @rudyfly |
@allencloud OK, i will add a new integration testcase. |
That could not be better. Thanks a lot. @xiaoxubeii |
@allencloud I find it is a little difficult to add a integration testcase of snapshot cleanup. That is because there is no api interface to list snapshots and i also cannot access containerd directly because of lacking the configuration. Any idea can help me to test? |
daemon/mgr/container.go
Outdated
@@ -303,6 +314,9 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty | |||
if err := mgr.Client.CreateSnapshot(ctx, id, config.Image); err != nil { | |||
return nil, err | |||
} | |||
cleanups = append(cleanups, func() { | |||
mgr.Client.RemoveSnapshot(ctx, id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add some log here?
@xiaoxubeii Thanks for your contribution. 🍻 |
LGTM |
Thanks for your great work. 🍺 @xiaoxubeii |
Ⅰ. Describe what this PR did
Fix that ContainerManager.Create wouldn't remove snapshot when failed.
Ⅱ. Does this pull request fix one issue?
fixes #2061.
Ⅲ. Describe how you did it
Add a variable cleanups to hold cleanup function, and loop it when failed in defer.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews