Merge pull request #19688 from crosbymichael/tmpfs-tar
Remove tar copy-up for tmpfs mounts Upstream-commit: 3a70ab3a2c78ab40a5fdfe55be5745753eb41139 Component: engine
This commit is contained in:
@ -437,7 +437,6 @@ func (d *Driver) setupMounts(container *configs.Config, c *execdriver.Command) e
|
||||
flags = syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV
|
||||
err error
|
||||
)
|
||||
fulldest := filepath.Join(c.Rootfs, m.Destination)
|
||||
if m.Data != "" {
|
||||
flags, data, err = mount.ParseTmpfsOptions(m.Data)
|
||||
if err != nil {
|
||||
@ -450,8 +449,6 @@ func (d *Driver) setupMounts(container *configs.Config, c *execdriver.Command) e
|
||||
Data: data,
|
||||
Device: "tmpfs",
|
||||
Flags: flags,
|
||||
PremountCmds: genTmpfsPremountCmd(c.TmpDir, fulldest, m.Destination),
|
||||
PostmountCmds: genTmpfsPostmountCmd(c.TmpDir, fulldest, m.Destination),
|
||||
PropagationFlags: []int{mountPropagationMap[volume.DefaultPropagationMode]},
|
||||
})
|
||||
continue
|
||||
|
||||
@ -1,56 +0,0 @@
|
||||
package native
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
)
|
||||
|
||||
func genTmpfsPremountCmd(tmpDir string, fullDest string, dest string) []configs.Command {
|
||||
var premount []configs.Command
|
||||
tarPath, err := exec.LookPath("tar")
|
||||
if err != nil {
|
||||
logrus.Warn("tar command is not available for tmpfs mount: %s", err)
|
||||
return premount
|
||||
}
|
||||
if _, err = exec.LookPath("rm"); err != nil {
|
||||
logrus.Warn("rm command is not available for tmpfs mount: %s", err)
|
||||
return premount
|
||||
}
|
||||
tarFile := fmt.Sprintf("%s/%s.tar", tmpDir, strings.Replace(dest, "/", "_", -1))
|
||||
if _, err := os.Stat(fullDest); err == nil {
|
||||
premount = append(premount, configs.Command{
|
||||
Path: tarPath,
|
||||
Args: []string{"-cf", tarFile, "-C", fullDest, "."},
|
||||
})
|
||||
}
|
||||
return premount
|
||||
}
|
||||
|
||||
func genTmpfsPostmountCmd(tmpDir string, fullDest string, dest string) []configs.Command {
|
||||
var postmount []configs.Command
|
||||
tarPath, err := exec.LookPath("tar")
|
||||
if err != nil {
|
||||
return postmount
|
||||
}
|
||||
rmPath, err := exec.LookPath("rm")
|
||||
if err != nil {
|
||||
return postmount
|
||||
}
|
||||
if _, err := os.Stat(fullDest); os.IsNotExist(err) {
|
||||
return postmount
|
||||
}
|
||||
tarFile := fmt.Sprintf("%s/%s.tar", tmpDir, strings.Replace(dest, "/", "_", -1))
|
||||
postmount = append(postmount, configs.Command{
|
||||
Path: tarPath,
|
||||
Args: []string{"-xf", tarFile, "-C", fullDest, "."},
|
||||
})
|
||||
return append(postmount, configs.Command{
|
||||
Path: rmPath,
|
||||
Args: []string{"-f", tarFile},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user