diff options
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 9ea9e02cd..2e0c24579 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -15,14 +15,14 @@ import ( "github.com/containers/buildah/copier" "github.com/containers/common/pkg/secrets" - "github.com/containers/podman/v2/libpod/define" - "github.com/containers/podman/v2/libpod/events" - "github.com/containers/podman/v2/pkg/cgroups" - "github.com/containers/podman/v2/pkg/ctime" - "github.com/containers/podman/v2/pkg/hooks" - "github.com/containers/podman/v2/pkg/hooks/exec" - "github.com/containers/podman/v2/pkg/rootless" - "github.com/containers/podman/v2/pkg/selinux" + "github.com/containers/podman/v3/libpod/define" + "github.com/containers/podman/v3/libpod/events" + "github.com/containers/podman/v3/pkg/cgroups" + "github.com/containers/podman/v3/pkg/ctime" + "github.com/containers/podman/v3/pkg/hooks" + "github.com/containers/podman/v3/pkg/hooks/exec" + "github.com/containers/podman/v3/pkg/rootless" + "github.com/containers/podman/v3/pkg/selinux" "github.com/containers/storage" "github.com/containers/storage/pkg/archive" "github.com/containers/storage/pkg/idtools" @@ -266,7 +266,7 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err c.newContainerEvent(events.Restart) // Increment restart count - c.state.RestartCount += 1 + c.state.RestartCount++ logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount) if err := c.save(); err != nil { return false, err @@ -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() @@ -1633,7 +1644,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) getOptions := copier.GetOptions{ KeepDirectoryNames: false, } - errChan <- copier.Get(mountpoint, "", getOptions, []string{v.Dest + "/."}, writer) + errChan <- copier.Get(srcDir, "", getOptions, []string{"/."}, writer) }() // Copy, volume side: stream what we've written to the pipe, into |