Skip to content

Commit

Permalink
remove usecases
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren de Lame committed Aug 1, 2024
1 parent f1e0cfe commit c5d9b1b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 272 deletions.
42 changes: 0 additions & 42 deletions granulate_utils/linux/containers.py

This file was deleted.

30 changes: 0 additions & 30 deletions granulate_utils/linux/ns.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,33 +333,3 @@ def resolve_host_path(process: Process, ns_path: str, from_ancestor: bool = True
Get a path in the host mount namespace pointing to path in process mount namespace.
"""
return resolve_proc_root_links(get_proc_root_path(process, from_ancestor=from_ancestor), ns_path)


def get_host_pid(nspid: int, container_id: str) -> Optional[int]:
assert len(container_id) == 64, f"Invalid container id {container_id!r}"

pid_namespace = ""
running_processes = list(process_iter())

# Get the pid namespace of the given container
for process in running_processes:
try:
if container_id == containers.get_process_container_id(process):
pid_namespace = os.readlink(f"/proc/{process.pid}/ns/pid")
break
except (FileNotFoundError, NoSuchProcess):
continue

if not pid_namespace:
return None

# Here we need to find the process by comparing pid namespaces and not by comparing cgroups, because
# technically a process that's running in a container pid namespace doesn't have to share its cgroup
for process in running_processes:
try:
if os.readlink(f"/proc/{process.pid}/ns/pid") == pid_namespace and get_process_nspid(process) == nspid:
return process.pid
except (FileNotFoundError, NoSuchProcess, PermissionError):
continue

return None
200 changes: 0 additions & 200 deletions tests/granulate_utils/test_cgroups.py

This file was deleted.

0 comments on commit c5d9b1b

Please sign in to comment.