-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add podman volume mount support #13318
Conversation
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.
Nice new feature. Some suggestions for the tests.
test/system/160-volumes.bats
Outdated
touch $mnt/$myfile | ||
run_podman run -v ${myvolume}:/vol1:z $IMAGE ls /vol1 | ||
is "$output" "$myfile" "$myfile should exists within the containers volume" |
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.
inconsistent indentation; mix of tabs and spaces. Also, s/exists/exist/
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.
Added a small test for rootless.
@@ -387,4 +387,27 @@ NeedsChown | true | |||
run_podman volume rm $myvolume | |||
} | |||
|
|||
@test "podman volume mount" { | |||
skip_if_remote "podman --remote volume mount not supported" |
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.
Test doesn't really do anything when rootless. Why not just skip_if_rootless
?
oh, and linter is unhappy
|
libpod/volume.go
Outdated
@@ -255,3 +255,11 @@ func (v *Volume) IsDangling() (bool, error) { | |||
func (v *Volume) UsesVolumeDriver() bool { | |||
return !(v.config.Driver == define.VolumeDriverLocal || v.config.Driver == "") | |||
} | |||
|
|||
func (v *Volume) Mount() (string, error) { | |||
return v.config.MountPoint, v.mount() |
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.
Need to v.lock.Lock(); defer v.lock.Unlock()
here and Unmount
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.
Thinking about this a bit more - v.config.MountPoint
may not be populated until v.mount()
runs (I think this is mostly a volume plugins thing), so it's safer to do err := v.mount(); return v.config.MountPoint, err
If you do a |
e7ce688
to
026821e
Compare
Since it is in a different mount namespace the unmount will not effect the running container. Tested this out with a tmpfs container. |
That isn't true? The volume mounts are made before the container is created, and then we bind-mount the mountpoint into the container - so there is no difference between a container requesting an unmount, and a user requesting an unmount, save for the fact that the container is still potentially running. I'm worried that we'll still set the mount counter to 0 if the unmount fails because the volume is in use, which would result in the volume being considered unmounted when it is still mounted. |
What I see is the mount point in the podman unshare aria shows the tmpfs is no longer mounted, but if I exec into the container I see the tmpfs is still mounted and the data I created on it it is still available. This is because in the containers mount namespace the file system is still mounted. |
@mheon from my testing, $ sudo bin/podman volume mount myvolume
/var/lib/containers/storage/volumes/myvolume/_data
$ sudo touch files in there, etc etc
$ sudo bin/podman volume rm myvolume
myvolume
$ sudo ls /var/lib/containers/storage/volumes/myvolume
ls: cannot access '/var/lib/containers/storage/volumes/myvolume': No such file or directory |
@edsantiago Did you make the volume with options that would require a mount take place - e.g. |
Uh, no, it was just a plain simple |
Ah - yeah, it's a short-circuit operation unless the volume actually needs a mount. Should probably make that clear in the manpages. It should always be safe to invoke mount and unmount, even on volumes that don't require a mount, to be clear; it's just that some volumes don't require them, and others do. I think the recommended workflow after the patches would always involve using them. |
I think the bind mount happens after the tmpfs mount which causes the tmpfs mount to leak into the mount namespace.
|
pkg/domain/infra/abi/volumes.go
Outdated
@@ -178,3 +178,35 @@ func (ic *ContainerEngine) VolumeMounted(ctx context.Context, nameOrID string) ( | |||
} | |||
return &entities.BoolReport{Value: false}, nil | |||
} | |||
|
|||
func (ic *ContainerEngine) VolumeMount(ctx context.Context, nameOrIDs []string) ([]*entities.ContainerMountReport, 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.
Do we want to use ContainerMountReport
or should we make a new type for VolumeMount
for consistency?
pkg/domain/infra/abi/volumes.go
Outdated
return reports, nil | ||
} | ||
|
||
func (ic *ContainerEngine) VolumeUnmount(ctx context.Context, nameOrIDs []string) ([]*entities.ContainerUnmountReport, 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.
Same as above, type consistency.
Fixes: containers#12768 Signed-off-by: Daniel J Walsh <[email protected]>
@containers/podman-maintainers PTAL |
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, giuseppe, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
/lgtm
Fixes: #12768
Signed-off-by: Daniel J Walsh [email protected]