-
Notifications
You must be signed in to change notification settings - Fork 564
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
Added fixes for issue #971(Mounted volume can be deleted
)
#974
Conversation
c7da7b8
to
cfdeb60
Compare
Mounted volume can be deleted
)
cmd/nerdctl/volume_rm.go
Outdated
if found = checkVolume(&mount.Mounts, volGet.Mountpoint); found { | ||
found = true | ||
var verr error | ||
verr = fmt.Errorf("%s %q %s", "Volume", name, "is in use") |
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.
No need to use %s
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.
Okay
cmd/nerdctl/volume_rm.go
Outdated
return err | ||
} | ||
defer cancel() | ||
containers, _ := client.Containers(ctx) |
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.
catch err
cmd/nerdctl/volume_rm.go
Outdated
if removednames != nil { | ||
rNames, err := volStore.Remove(removednames) | ||
if err != nil { | ||
panic(err) |
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.
why panic
cfdeb60
to
a2c58e6
Compare
d029bff
to
07e7a21
Compare
cmd/nerdctl/volume_rm.go
Outdated
if removednames != nil { | ||
rNames, err := volStore.Remove(removednames) | ||
if err != nil { | ||
panic(err) |
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.
I think just return error directly would be better
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.
Ill change it.
cmd/nerdctl/volume_rm.go
Outdated
return err | ||
} | ||
var mount *specs.Spec | ||
var removednames []string |
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.
var removedNames
would be better?
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.
I used it for volumes that have to be deleted.
4cc0d23
to
839faf5
Compare
Signed-off-by: Raymond Mathew <raymond.mathew@click2cloud.net>
Fixed issue #971
In this PR, if the volume is mounted, it doesn't allow the volume to be removed.