-
Notifications
You must be signed in to change notification settings - Fork 950
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
feature: add "volume" flag when remove container #1255
Conversation
954cd17
to
fe64515
Compare
Codecov Report
@@ Coverage Diff @@
## master #1255 +/- ##
==========================================
+ Coverage 15.24% 15.28% +0.04%
==========================================
Files 172 172
Lines 10715 10684 -31
==========================================
Hits 1633 1633
+ Misses 8962 8930 -32
- Partials 120 121 +1
|
cli/rm.go
Outdated
flagSet := r.cmd.Flags() | ||
|
||
flagSet.BoolVarP(&r.force, "force", "f", false, "if the container is running, force to remove it") | ||
flagSet.BoolVarP(&r.removeVolume, "volumes", "v", false, "remove container's volumes that create by the container") |
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.
it's better to use removeVolume
instead of removeVolumes
daemon/mgr/container.go
Outdated
@@ -2271,6 +2271,12 @@ func (mgr *ContainerManager) detachVolumes(ctx context.Context, c *ContainerMeta | |||
} | |||
|
|||
mgr.VolumeMgr.Detach(ctx, name, option) |
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.
Detach
is to umount
volume mountpoint, so if the volume is attached to multi containers, does this action will cause other containers' volumes unused?
Another thing: do we distinct volumes created by user and pouchd, because users may delete volumes created by themself, so we just need delete volumes created by pouchd?
test/environment/cleanup.go
Outdated
@@ -4,6 +4,7 @@ import ( | |||
"context" | |||
"fmt" | |||
|
|||
"github.com/alibaba/pouch/apis/types" | |||
"github.com/alibaba/pouch/client" | |||
"github.com/pkg/errors" |
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.
add new blank line here
3eed41b
to
50fd6cd
Compare
PTAL @HusterWan @fuweid |
client/container_remove_test.go
Outdated
@@ -24,7 +26,7 @@ func TestContainerRemoveNotFoundError(t *testing.T) { | |||
client := &APIClient{ | |||
HTTPCli: newMockClient(errorMockResponse(http.StatusNotFound, "Not Found")), | |||
} | |||
err := client.ContainerRemove(context.Background(), "no contaienr", true) | |||
err := client.ContainerRemove(context.Background(), "no contaienr", &types.ContainerRemoveOptions{Force: true}) |
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.
%s/contaienr/container :)
daemon/mgr/volume.go
Outdated
} | ||
|
||
cid, ok := options[types.OptionRef] | ||
if ok && len(cid) != 0 { |
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.
cid == "" will be better WDYT???
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.
@HusterWan I think two kinds are the same. Just keep the consistent in one project.
Add "volume" flag when remove container, it is used to remove these volumes that is created by container. Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
LGTM |
Ⅰ. Describe what this PR did
Add "volume" flag when remove container, it is used to remove these
volumes that is created by container.
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
-v
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com