Ejemplo n.º 1
0
 def test_running_under_container_runtime(self, container_runtime_id):
     with tempfile.NamedTemporaryFile() as proc_one_cgroup:
         proc_one_cgroup.write(container_runtime_id.encode())
         proc_one_cgroup.write(b'\n')
         proc_one_cgroup.flush()
         self.assertTrue(
             utils.running_under_container_runtime(proc_one_cgroup.name))
Ejemplo n.º 2
0
def _get_cni_cgroup_path():
    """Returns the path to the CNI process cgroup memory directory."""
    if utils.running_under_container_runtime():
        # We are running inside a container. This means the root cgroup
        # is the one we need to track as it will be the CNI parent proc
        cg_memsw_path = TOP_CGROUP_MEMORY_PATH
    else:
        cg_memsw_path = CONF.cni_health_server.cg_path

    return cg_memsw_path
Ejemplo n.º 3
0
 def test_not_running_under_container_runtime(self):
     with tempfile.NamedTemporaryFile() as proc_one_cgroup:
         self.assertFalse(
             utils.running_under_container_runtime(proc_one_cgroup.name))