def test_find_cgroup_devices_path_centos(self, mock):
     mock.return_value = [
         'none /sys/fs/cgroup cgroup rw,relatime,perf_event,'
             'blkio,net_cls,freezer,devices,memory,cpuacct,cpu,'
             'cpuset 0 0']
     path = hostinfo.get_cgroup_devices_path()
     self.assertEqual('/sys/fs/cgroup', path)
Beispiel #2
0
 def _find_container_pid(self, container_id):
     cgroup_path = hostinfo.get_cgroup_devices_path()
     lxc_path = os.path.join(cgroup_path, 'lxc')
     tasks_path = os.path.join(lxc_path, container_id, 'tasks')
     n = 0
     while True:
         # NOTE(samalba): We wait for the process to be spawned inside the
         # container in order to get the the "container pid". This is
         # usually really fast. To avoid race conditions on a slow
         # machine, we allow 10 seconds as a hard limit.
         if n > 20:
             return
         try:
             with open(tasks_path) as f:
                 pids = f.readlines()
                 if pids:
                     return int(pids[0].strip())
         except IOError:
             pass
         time.sleep(0.5)
         n += 1
Beispiel #3
0
 def _find_container_pid(self, container_id):
     cgroup_path = hostinfo.get_cgroup_devices_path()
     lxc_path = os.path.join(cgroup_path, 'lxc')
     tasks_path = os.path.join(lxc_path, container_id, 'tasks')
     n = 0
     while True:
         # NOTE(samalba): We wait for the process to be spawned inside the
         # container in order to get the the "container pid". This is
         # usually really fast. To avoid race conditions on a slow
         # machine, we allow 10 seconds as a hard limit.
         if n > 20:
             return
         try:
             with open(tasks_path) as f:
                 pids = f.readlines()
                 if pids:
                     return int(pids[0].strip())
         except IOError:
             pass
         time.sleep(0.5)
         n += 1
 def test_find_cgroup_devices_path_ubuntu(self, mock):
     mock.return_value = ['cgroup /cgroup tmpfs rw,relatime,mode=755 0 0',
             'cgroup /cgroup/devices cgroup rw,relatime,devices,' +
             'clone_children 0 0']
     path = hostinfo.get_cgroup_devices_path()
     self.assertEqual('/cgroup/devices', path)