This is fix for proper setup of nested containers cgroups.
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
| ... | ... |
@@ -36,7 +36,7 @@ clone git github.com/hashicorp/consul v0.5.2 |
| 36 | 36 |
# get distribution packages |
| 37 | 37 |
clone git github.com/docker/distribution 419bbc2da637d9b2a812be78ef8436df7caac70d |
| 38 | 38 |
|
| 39 |
-clone git github.com/opencontainers/runc v0.0.1 # libcontainer |
|
| 39 |
+clone git github.com/opencontainers/runc v0.0.2 # libcontainer |
|
| 40 | 40 |
# libcontainer deps (see src/github.com/docker/libcontainer/update-vendor.sh) |
| 41 | 41 |
clone git github.com/coreos/go-systemd v2 |
| 42 | 42 |
clone git github.com/godbus/dbus v2 |
| ... | ... |
@@ -235,16 +235,20 @@ func getCgroupData(c *configs.Cgroup, pid int) (*data, error) {
|
| 235 | 235 |
}, nil |
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 |
-func (raw *data) parent(subsystem, mountpoint string) (string, error) {
|
|
| 238 |
+func (raw *data) parent(subsystem, mountpoint, src string) (string, error) {
|
|
| 239 | 239 |
initPath, err := cgroups.GetInitCgroupDir(subsystem) |
| 240 | 240 |
if err != nil {
|
| 241 | 241 |
return "", err |
| 242 | 242 |
} |
| 243 |
- return filepath.Join(mountpoint, initPath), nil |
|
| 243 |
+ relDir, err := filepath.Rel(src, initPath) |
|
| 244 |
+ if err != nil {
|
|
| 245 |
+ return "", err |
|
| 246 |
+ } |
|
| 247 |
+ return filepath.Join(mountpoint, relDir), nil |
|
| 244 | 248 |
} |
| 245 | 249 |
|
| 246 | 250 |
func (raw *data) path(subsystem string) (string, error) {
|
| 247 |
- mnt, err := cgroups.FindCgroupMountpoint(subsystem) |
|
| 251 |
+ mnt, src, err := cgroups.FindCgroupMountpointAndSource(subsystem) |
|
| 248 | 252 |
// If we didn't mount the subsystem, there is no point we make the path. |
| 249 | 253 |
if err != nil {
|
| 250 | 254 |
return "", err |
| ... | ... |
@@ -255,7 +259,7 @@ func (raw *data) path(subsystem string) (string, error) {
|
| 255 | 255 |
return filepath.Join(raw.root, subsystem, raw.cgroup), nil |
| 256 | 256 |
} |
| 257 | 257 |
|
| 258 |
- parent, err := raw.parent(subsystem, mnt) |
|
| 258 |
+ parent, err := raw.parent(subsystem, mnt, src) |
|
| 259 | 259 |
if err != nil {
|
| 260 | 260 |
return "", err |
| 261 | 261 |
} |
| ... | ... |
@@ -42,6 +42,28 @@ func FindCgroupMountpoint(subsystem string) (string, error) {
|
| 42 | 42 |
return "", NewNotFoundError(subsystem) |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
+func FindCgroupMountpointAndSource(subsystem string) (string, string, error) {
|
|
| 46 |
+ f, err := os.Open("/proc/self/mountinfo")
|
|
| 47 |
+ if err != nil {
|
|
| 48 |
+ return "", "", err |
|
| 49 |
+ } |
|
| 50 |
+ scanner := bufio.NewScanner(f) |
|
| 51 |
+ for scanner.Scan() {
|
|
| 52 |
+ txt := scanner.Text() |
|
| 53 |
+ fields := strings.Split(txt, " ") |
|
| 54 |
+ for _, opt := range strings.Split(fields[len(fields)-1], ",") {
|
|
| 55 |
+ if opt == subsystem {
|
|
| 56 |
+ return fields[4], fields[3], nil |
|
| 57 |
+ } |
|
| 58 |
+ } |
|
| 59 |
+ } |
|
| 60 |
+ if err := scanner.Err(); err != nil {
|
|
| 61 |
+ return "", "", err |
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ return "", "", NewNotFoundError(subsystem) |
|
| 65 |
+} |
|
| 66 |
+ |
|
| 45 | 67 |
func FindCgroupMountpointDir() (string, error) {
|
| 46 | 68 |
mounts, err := mount.GetMounts() |
| 47 | 69 |
if err != nil {
|