-
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
bugfix: fix volume can be removed when using by container #888
Conversation
daemon/mgr/container.go
Outdated
@@ -192,6 +192,10 @@ func (mgr *ContainerManager) Remove(ctx context.Context, name string, option *Co | |||
} | |||
} | |||
|
|||
if err := mgr.deatchVolumes(ctx, c.meta); err != nil { |
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/deatch/detach?
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.
yes, I have made a mistake.
daemon/mgr/container.go
Outdated
@@ -1028,6 +1048,42 @@ func (mgr *ContainerManager) parseVolumes(ctx context.Context, c *types.Containe | |||
return nil | |||
} | |||
|
|||
func (mgr *ContainerManager) deatchVolumes(ctx context.Context, c *ContainerMeta) error { |
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?
CI fails, and it is not a flaky test, since in travis CI we have recorded the following log:
|
Codecov Report
@@ Coverage Diff @@
## master #888 +/- ##
==========================================
- Coverage 13.66% 13.59% -0.07%
==========================================
Files 121 121
Lines 7667 7706 +39
==========================================
Hits 1048 1048
- Misses 6529 6568 +39
Partials 90 90
Continue to review full report at Codecov.
|
daemon/mgr/container.go
Outdated
if id != c.ID { | ||
newRef = append(newRef, 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 wrap a function like this:
func remove(s []string, r string) []string {
for i, v := range s {
if v == r {
return append(s[:i], s[i+1:]...)
}
}
return s
}
Could refer: https://stackoverflow.com/questions/34070369/removing-a-string-from-a-slice-in-go
Could you also add tests for it? Or you could open an issue to record this. |
fix volume can be removed when using by container. Signed-off-by: Rudy Zhang <[email protected]>
@Letty5411 PTAL |
LGTM |
Ⅰ. Describe what this PR did
fix volume can be removed when using by container.
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how you did it
mark container's id into volume option "ref" when container attach volume, and remove option "ref" when container deatch volume.
Ⅳ. Describe how to verify it
create volume and run container.
check volume option ref
remove container and then check volume option ref.
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang [email protected]