summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-01-07 20:38:59 +0100
committerGitHub <noreply@github.com>2022-01-07 20:38:59 +0100
commit41934acc51c5046a56b17158d7f2b735961864ce (patch)
tree99a6768250c51635a7d3602e2f657a88b94b7fca /libpod
parent0464011a8ea705b31cf270407e76608c223c2f21 (diff)
parent13f3fd2555b1f02af4c183ef51d1707af1198eb9 (diff)
downloadpodman-41934acc51c5046a56b17158d7f2b735961864ce.tar.gz
podman-41934acc51c5046a56b17158d7f2b735961864ce.tar.bz2
podman-41934acc51c5046a56b17158d7f2b735961864ce.zip
Merge pull request #12733 from rhatdan/copy
Set volume NeedsCopyUp to false iff data was copied up
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal.go14
-rw-r--r--libpod/define/volume_inspect.go8
-rw-r--r--libpod/volume_inspect.go3
3 files changed, 18 insertions, 7 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 33bb35a0b..12d6d5a18 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1691,13 +1691,6 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
if vol.state.NeedsCopyUp {
logrus.Debugf("Copying up contents from container %s to volume %s", c.ID(), vol.Name())
- // Set NeedsCopyUp to false immediately, so we don't try this
- // again when there are already files copied.
- vol.state.NeedsCopyUp = false
- if err := vol.save(); err != nil {
- return nil, err
- }
-
// If the volume is not empty, we should not copy up.
volMount := vol.mountPoint()
contents, err := ioutil.ReadDir(volMount)
@@ -1744,6 +1737,13 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
return vol, nil
}
+ // Set NeedsCopyUp to false since we are about to do first copy
+ // Do not copy second time.
+ vol.state.NeedsCopyUp = false
+ if err := vol.save(); err != nil {
+ return nil, err
+ }
+
// Buildah Copier accepts a reader, so we'll need a pipe.
reader, writer := io.Pipe()
defer reader.Close()
diff --git a/libpod/define/volume_inspect.go b/libpod/define/volume_inspect.go
index 20602ea16..fac179176 100644
--- a/libpod/define/volume_inspect.go
+++ b/libpod/define/volume_inspect.go
@@ -48,4 +48,12 @@ type InspectVolumeData struct {
// volume for a specific container, and will be be removed when any
// container using it is removed.
Anonymous bool `json:"Anonymous,omitempty"`
+ // MountCount is the number of times this volume has been mounted.
+ MountCount uint `json:"MountCount"`
+ // NeedsCopyUp indicates that the next time the volume is mounted into
+ NeedsCopyUp bool `json:"NeedsCopyUp,omitempty"`
+ // NeedsChown indicates that the next time the volume is mounted into
+ // a container, the container will chown the volume to the container process
+ // UID/GID.
+ NeedsChown bool `json:"NeedsChown,omitempty"`
}
diff --git a/libpod/volume_inspect.go b/libpod/volume_inspect.go
index c3f51222d..70098df5a 100644
--- a/libpod/volume_inspect.go
+++ b/libpod/volume_inspect.go
@@ -60,6 +60,9 @@ func (v *Volume) Inspect() (*define.InspectVolumeData, error) {
data.UID = v.uid()
data.GID = v.gid()
data.Anonymous = v.config.IsAnon
+ data.MountCount = v.state.MountCount
+ data.NeedsCopyUp = v.state.NeedsCopyUp
+ data.NeedsChown = v.state.NeedsChown
return data, nil
}