mesosphere-backup / deimos

Mesos containerizer hooks for Docker
Apache License 2.0
249 stars 26 forks source link

Container info in /cgroups on CentOS 6.5 #40

Closed ssorallen closed 10 years ago

ssorallen commented 10 years ago

I have a question about deimos and centos 6.5 . I install mesos and docker but i have a problem with deimos . I check the source code and I found the problem (https://github.com/mesosphere/deimos/blob/master/deimos/docker.py#L109) I don’t know why in centos docker save the container information in /cgroups/. Any idea how to fix that ?

ssalvatori commented 10 years ago

I have the same problem, I tried changing the path in the deimos source but now I have a problem with memory attribute for the cgroups object

ssalvatori commented 10 years ago

I made a little change in deimos to work with centos 6.5 and kernel 3.15.*

[root@tmparq deimos]# uname -a Linux tmparq.cloud.lan.com 3.15.3-1.el6.elrepo.x86_64 #1 SMP Tue Jul 1 12:42:44 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

diff --git a/deimos/docker.py b/deimos/docker.py
index b268624..90315c4 100644
--- a/deimos/docker.py
+++ b/deimos/docker.py
@@ -106,9 +106,9 @@ class Status(_Struct):

 def cgroups(cid):
     paths = []
-    paths += glob.glob("/sys/fs/cgroup/*/" + cid)
-    paths += glob.glob("/sys/fs/cgroup/*/docker/" + cid)
-    return dict((s.split("/")[4], s) for s in paths)
+    paths += glob.glob("/cgroup/*/" + cid)
+    paths += glob.glob("/cgroup/*/docker/" + cid)
+    return dict((s.split("/")[2], s) for s in paths)
solidsnack commented 10 years ago

Maybe something like this would work everywhere?

diff --git a/deimos/docker.py b/deimos/docker.py
index b268624..7d5eef0 100644
--- a/deimos/docker.py
+++ b/deimos/docker.py
@@ -108,7 +108,10 @@ def cgroups(cid):
     paths = []
     paths += glob.glob("/sys/fs/cgroup/*/" + cid)
     paths += glob.glob("/sys/fs/cgroup/*/docker/" + cid)
-    return dict((s.split("/")[4], s) for s in paths)
+    paths += glob.glob("/cgroup/*/" + cid)
+    paths += glob.glob("/cgroup/*/docker/" + cid)
+    named_cgroups = [(s.split("/cgroup/")[1].split("/")[0], s) for s in paths]
+    return dict(named_cgroups)

 def matching_image_for_host(distro=None, release=None, *args, **kwargs):
zircote commented 10 years ago

@solidsnack, thank you. That corrects the issue succinctly, will that be included in a near future version?