diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-17 13:18:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 13:18:33 -0500 |
commit | d48f4a0e1f3d24fb4f98351b5bdd31daa34c0fb6 (patch) | |
tree | b1212d8483f5a4d641f129cbbb273f6be6574271 | |
parent | 6ea9ff2f21b583e4bc61a72d97c889ee7057a32e (diff) | |
parent | 759fc933438dead681a0c4f3d9e17826b0dc18cc (diff) | |
download | podman-d48f4a0e1f3d24fb4f98351b5bdd31daa34c0fb6.tar.gz podman-d48f4a0e1f3d24fb4f98351b5bdd31daa34c0fb6.tar.bz2 podman-d48f4a0e1f3d24fb4f98351b5bdd31daa34c0fb6.zip |
Merge pull request #9383 from mheon/fix_copyup_empty
Fix an issue where copyup could fail with ENOENT
-rw-r--r-- | libpod/container_internal.go | 11 | ||||
-rw-r--r-- | test/e2e/run_volume_test.go | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index ced357096..ca0e082ff 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1617,6 +1617,17 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) if !srcStat.IsDir() { return vol, nil } + // Read contents, do not bother continuing if it's empty. Fixes + // a bizarre issue where something copier.Get will ENOENT on + // empty directories and sometimes it will not. + // RHBZ#1928643 + srcContents, err := ioutil.ReadDir(srcDir) + if err != nil { + return nil, errors.Wrapf(err, "error reading contents of source directory for copy up into volume %s", vol.Name()) + } + if len(srcContents) == 0 { + return vol, nil + } // Buildah Copier accepts a reader, so we'll need a pipe. reader, writer := io.Pipe() diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index 19d82c974..91d8f15f4 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -322,6 +322,18 @@ RUN sh -c "cd /etc/apk && ln -s ../../testfile"` Expect(outputSession.OutputToString()).To(Equal(baselineOutput)) }) + It("podman named volume copyup empty directory", func() { + baselineSession := podmanTest.Podman([]string{"run", "--rm", "-t", "-i", ALPINE, "ls", "/srv"}) + baselineSession.WaitWithDefaultTimeout() + Expect(baselineSession.ExitCode()).To(Equal(0)) + baselineOutput := baselineSession.OutputToString() + + outputSession := podmanTest.Podman([]string{"run", "-t", "-i", "-v", "/srv", ALPINE, "ls", "/srv"}) + outputSession.WaitWithDefaultTimeout() + Expect(outputSession.ExitCode()).To(Equal(0)) + Expect(outputSession.OutputToString()).To(Equal(baselineOutput)) + }) + It("podman read-only tmpfs conflict with volume", func() { session := podmanTest.Podman([]string{"run", "--rm", "-t", "-i", "--read-only", "-v", "tmp_volume:" + dest, ALPINE, "touch", dest + "/a"}) session.WaitWithDefaultTimeout() |