Browse code

Update libcontainer to 2c3115481ee1782ad687a9e0b4834f89533c2acf

It includes fix for parsing systemd cgroup names

Signed-off-by: Alexander Morozov <lk4d4@docker.com>

Alexander Morozov authored on 2016/02/24 06:37:20
Showing 5 changed files
... ...
@@ -59,7 +59,7 @@ clone git github.com/miekg/pkcs11 80f102b5cac759de406949c47f0928b99bd64cdf
59 59
 clone git github.com/docker/go v1.5.1-1-1-gbaf439e
60 60
 clone git github.com/agl/ed25519 d2b94fd789ea21d12fac1a4443dd3a3f79cda72c
61 61
 
62
-clone git github.com/opencontainers/runc ce72f86a2b54bc114d6ffb51f6500479b2d42154 # libcontainer
62
+clone git github.com/opencontainers/runc 2c3115481ee1782ad687a9e0b4834f89533c2acf # libcontainer
63 63
 clone git github.com/seccomp/libseccomp-golang 1b506fc7c24eec5a3693cdcbed40d9c226cfc6a1
64 64
 # libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json)
65 65
 clone git github.com/coreos/go-systemd v4
... ...
@@ -31,6 +31,7 @@ var (
31 31
 		&NetPrioGroup{},
32 32
 		&PerfEventGroup{},
33 33
 		&FreezerGroup{},
34
+		&NameGroup{GroupName: "name=systemd", Join: true},
34 35
 	}
35 36
 	CgroupProcesses  = "cgroup.procs"
36 37
 	HugePageSizes, _ = cgroups.GetHugePageSize()
... ...
@@ -130,11 +131,6 @@ func (m *Manager) Apply(pid int) (err error) {
130 130
 	}
131 131
 
132 132
 	paths := make(map[string]string)
133
-	defer func() {
134
-		if err != nil {
135
-			cgroups.RemovePaths(paths)
136
-		}
137
-	}()
138 133
 	for _, sys := range subsystems {
139 134
 		if err := sys.Apply(d); err != nil {
140 135
 			return err
... ...
@@ -5,6 +5,7 @@ package fs
5 5
 import (
6 6
 	"github.com/opencontainers/runc/libcontainer/cgroups"
7 7
 	"github.com/opencontainers/runc/libcontainer/configs"
8
+	"github.com/opencontainers/runc/libcontainer/system"
8 9
 )
9 10
 
10 11
 type DevicesGroup struct {
... ...
@@ -25,6 +26,10 @@ func (s *DevicesGroup) Apply(d *cgroupData) error {
25 25
 }
26 26
 
27 27
 func (s *DevicesGroup) Set(path string, cgroup *configs.Cgroup) error {
28
+	if system.RunningInUserNS() {
29
+		return nil
30
+	}
31
+
28 32
 	devices := cgroup.Resources.Devices
29 33
 	if len(devices) > 0 {
30 34
 		for _, dev := range devices {
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 type NameGroup struct {
11 11
 	GroupName string
12
+	Join      bool
12 13
 }
13 14
 
14 15
 func (s *NameGroup) Name() string {
... ...
@@ -16,6 +17,10 @@ func (s *NameGroup) Name() string {
16 16
 }
17 17
 
18 18
 func (s *NameGroup) Apply(d *cgroupData) error {
19
+	if s.Join {
20
+		// ignore errors if the named cgroup does not exist
21
+		d.join(s.GroupName)
22
+	}
19 23
 	return nil
20 24
 }
21 25
 
... ...
@@ -24,6 +29,9 @@ func (s *NameGroup) Set(path string, cgroup *configs.Cgroup) error {
24 24
 }
25 25
 
26 26
 func (s *NameGroup) Remove(d *cgroupData) error {
27
+	if s.Join {
28
+		removePath(d.path(s.GroupName))
29
+	}
27 30
 	return nil
28 31
 }
29 32
 
... ...
@@ -126,11 +126,11 @@ func getCgroupMountsHelper(ss map[string]bool, mi io.Reader) ([]Mount, error) {
126 126
 	scanner := bufio.NewScanner(mi)
127 127
 	for scanner.Scan() {
128 128
 		txt := scanner.Text()
129
-		sepIdx := strings.IndexByte(txt, '-')
129
+		sepIdx := strings.Index(txt, " - ")
130 130
 		if sepIdx == -1 {
131 131
 			return nil, fmt.Errorf("invalid mountinfo format")
132 132
 		}
133
-		if txt[sepIdx+2:sepIdx+8] != "cgroup" {
133
+		if txt[sepIdx+3:sepIdx+9] != "cgroup" {
134 134
 			continue
135 135
 		}
136 136
 		fields := strings.Split(txt, " ")