Browse Source

Merge pull request #11416 from mrunalp/update_libcontainer

Update libcontainer to 52a8c004ca94cf98f6866536de828c71eb42d1ec
Michael Crosby 10 years ago
parent
commit
8a6a5929a3

+ 1 - 1
hack/vendor.sh

@@ -68,7 +68,7 @@ if [ "$1" = '--go' ]; then
 	mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar
 fi
 
-clone git github.com/docker/libcontainer 5d6c507d7cfeff97172deedf3db13b5295bcacef
+clone git github.com/docker/libcontainer 52a8c004ca94cf98f6866536de828c71eb42d1ec
 # see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
 rm -rf src/github.com/docker/libcontainer/vendor
 eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli' | grep -v 'github.com/Sirupsen/logrus')"

+ 1 - 1
vendor/src/github.com/docker/libcontainer/Dockerfile

@@ -9,7 +9,7 @@ RUN go get github.com/docker/docker/pkg/term
 RUN mkdir /busybox && \
     curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -xC /busybox
 
-RUN curl -sSL https://raw.githubusercontent.com/docker/docker/master/project/dind -o /dind && \
+RUN curl -sSL https://raw.githubusercontent.com/docker/docker/master/hack/dind -o /dind && \
     chmod +x /dind
 
 COPY . /go/src/github.com/docker/libcontainer

+ 11 - 14
vendor/src/github.com/docker/libcontainer/cgroups/fs/apply_raw.go

@@ -99,11 +99,12 @@ func (m *Manager) Apply(pid int) error {
 		// created then join consists of writing the process pids to cgroup.procs
 		p, err := d.path(name)
 		if err != nil {
-			if cgroups.IsNotFound(err) {
-				continue
-			}
 			return err
 		}
+		if !cgroups.PathExists(p) {
+			continue
+		}
+
 		paths[name] = p
 	}
 	m.Paths = paths
@@ -173,6 +174,9 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
 	if err != nil {
 		return err
 	}
+	if !cgroups.PathExists(dir) {
+		return cgroups.NewNotFoundError("freezer")
+	}
 
 	prevState := m.Cgroups.Freezer
 	m.Cgroups.Freezer = state
@@ -197,6 +201,9 @@ func (m *Manager) GetPids() ([]int, error) {
 	if err != nil {
 		return nil, err
 	}
+	if !cgroups.PathExists(dir) {
+		return nil, cgroups.NewNotFoundError("devices")
+	}
 
 	return cgroups.ReadProcsFile(dir)
 }
@@ -237,17 +244,7 @@ func (raw *data) path(subsystem string) (string, error) {
 
 	// If the cgroup name/path is absolute do not look relative to the cgroup of the init process.
 	if filepath.IsAbs(raw.cgroup) {
-		path := filepath.Join(raw.root, subsystem, raw.cgroup)
-
-		if _, err := os.Stat(path); err != nil {
-			if os.IsNotExist(err) {
-				return "", cgroups.NewNotFoundError(subsystem)
-			}
-
-			return "", err
-		}
-
-		return path, nil
+		return filepath.Join(raw.root, subsystem, raw.cgroup), nil
 	}
 
 	parent, err := raw.parent(subsystem)

+ 2 - 5
vendor/src/github.com/docker/libcontainer/cgroups/fs/cpuset.go

@@ -17,12 +17,9 @@ type CpusetGroup struct {
 func (s *CpusetGroup) Apply(d *data) error {
 	dir, err := d.path("cpuset")
 	if err != nil {
-		if cgroups.IsNotFound(err) {
-			return nil
-		} else {
-			return err
-		}
+		return err
 	}
+
 	return s.ApplyDir(dir, d.c, d.pid)
 }
 

+ 1 - 1
vendor/src/github.com/docker/libcontainer/container_linux_test.go

@@ -125,7 +125,7 @@ func TestGetContainerState(t *testing.T) {
 	container := &linuxContainer{
 		id: "myid",
 		config: &configs.Config{
-			Namespaces: configs.Namespaces{
+			Namespaces: []configs.Namespace{
 				{Type: configs.NEWPID},
 				{Type: configs.NEWNS},
 				{Type: configs.NEWNET, Path: expectedNetworkPath},

+ 2 - 0
vendor/src/github.com/docker/libcontainer/hack/validate.sh

@@ -7,6 +7,8 @@ validate() {
     sed -i 's!docker/docker!docker/libcontainer!' /go/src/github.com/docker/docker/hack/make/.validate
     bash /go/src/github.com/docker/docker/hack/make/validate-dco
     bash /go/src/github.com/docker/docker/hack/make/validate-gofmt
+    go get golang.org/x/tools/cmd/vet
+    go vet github.com/docker/libcontainer/...
 }
 
 # run validations

+ 2 - 6
vendor/src/github.com/docker/libcontainer/rootfs_linux.go

@@ -95,7 +95,7 @@ func mount(m *configs.Mount, rootfs, mountLabel string) error {
 	}
 
 	switch m.Device {
-	case "proc":
+	case "proc", "mqueue", "sysfs":
 		if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
 			return err
 		}
@@ -116,14 +116,10 @@ func mount(m *configs.Mount, rootfs, mountLabel string) error {
 			}
 		}
 		return nil
-	case "mqueue", "devpts", "sysfs":
+	case "devpts":
 		if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
 			return err
 		}
-		if m.Device == "mqueue" {
-			// mqueue should not be labeled, otherwise the mount will fail
-			data = ""
-		}
 		return syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data)
 	case "bind":
 		stat, err := os.Stat(m.Source)

+ 5 - 0
vendor/src/github.com/docker/libcontainer/selinux/selinux.go

@@ -159,6 +159,11 @@ func Setfilecon(path string, scon string) error {
 // Getfilecon returns the SELinux label for this path or returns an error.
 func Getfilecon(path string) (string, error) {
 	con, err := system.Lgetxattr(path, xattrNameSelinux)
+
+	// Trim the NUL byte at the end of the byte buffer, if present.
+	if con[len(con)-1] == '\x00' {
+		con = con[:len(con)-1]
+	}
 	return string(con), err
 }