Skip to content

Commit

Permalink
validate: Drop mount checks
Browse files Browse the repository at this point in the history
These landed as CheckMounts in 647e355 (bundle validate update to
0.3.0, 2016-02-23, #20), but both checks are too strict.

The first (destination exists in the rootfs) errors on valid cases
like:

  "mounts": [
    {
      "source": "users",
      "destination": "/home",
      "type": "bind"
    },
    {
      "source": "none",
      "destination": "/home/wking",
      "type": "tmpfs"
    }
  ]

Where the source 'users' directory already contained a 'wking'
subdirectory.  So by the time the tmpfs was setup, the destination
directory would exist, but at validation time (without having run the
bind mount) the tmpfs destination directory would not exist.

The second (destination is a directory) errors on valid cases like:

  "mounts": [
    {
      "source": "/etc/resolv.conf",
      "destination": "/etc/resolv.conf",
      "type": "bind"
    }
  ]

because binding files to files works.  In a shell:

  # touch test
  # mount --bind /etc/resolv.conf test
  # umount test

However binding directories to files does not work:

  # mount --bind /etc test
  mount: mount point /tmp/test is not a directory

Figuring out which mount configurations are valid and which aren't may
be possible, but I'm pretty sure it's more trouble than we want to get
into.  There may be room for other mount tests (e.g. comparing 'type'
against /proc/filesystems as a host-specific test), but I'm leaving
those to subsequent pull requests.

Signed-off-by: W. Trevor King <wking@tremily.us>
  • Loading branch information
wking committed May 23, 2016
1 parent a637b56 commit db4632b
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func bundleValidate(spec rspec.Spec, rootfs string) {
checkSemVer(spec.Version)
checkPlatform(spec.Platform)
checkProcess(spec.Process, rootfs)
checkMounts(spec.Mounts, rootfs)
checkLinux(spec.Linux, rootfs)
}

Expand All @@ -97,17 +96,6 @@ func checkSemVer(version string) {
}
}

func checkMounts(mounts []rspec.Mount, rootfs string) {
for _, mount := range mounts {
destPath := path.Join(rootfs, mount.Destination)
if fi, err := os.Stat(destPath); err != nil {
logrus.Fatalf("Cannot find the mount destination %q", destPath)
} else if !fi.IsDir() {
logrus.Fatalf("Mount destination %q is not a directory.", destPath)
}
}
}

func checkPlatform(platform rspec.Platform) {
validCombins := map[string][]string{
"darwin": {"386", "amd64", "arm", "arm64"},
Expand Down

0 comments on commit db4632b

Please sign in to comment.