mafw.devtools.dependencies.resources
Runtime resource reporting utilities for dependency verification.
This module provides a small, best-effort diagnostic helper used by the
dependency verification commands (latest and oldest) to dump the
amount of resources still available on the CI runner after each test phase
and for each Python version.
The information collected here is primarily meant to debug situations in which a long-running CI job stalls or is killed by the orchestrator because the pod exhausts a resource (disk space, inodes, memory or CPU quota). The helper intentionally never raises: a diagnostic probe must not be able to abort the job it is supposed to observe.
- author:
Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
Module Attributes
Shell commands used to inspect disk usage, as |
|
cgroup v2 pseudo-files inspected to report memory and CPU quota usage. |
Functions
|
Print a best-effort snapshot of the resources left on the runner. |
- mafw.devtools.dependencies.resources._probe_cgroup_file(label: str, path: str) None[source]
Read a cgroup pseudo-file and print its content, swallowing any error.
- Parameters:
label (str) – Human-readable description shown before the output.
path (str) – Absolute path of the cgroup pseudo-file to read.
- mafw.devtools.dependencies.resources._probe_shell(label: str, command: str) None[source]
Run a shell probe and print its output, swallowing any error.
- Parameters:
label (str) – Human-readable description shown before the output.
command (str) – Shell command to execute (e.g.
df -h).
- mafw.devtools.dependencies.resources.report_resources(context: str) None[source]
Print a best-effort snapshot of the resources left on the runner.
The snapshot includes disk usage (
df -handdf -i) and cgroup v2 memory and CPU statistics. All probes are best-effort: any failure to run a command or to read a pseudo-file is reported inline and never propagated, so the diagnostics cannot abort the verification job.- Parameters:
context (str) – Short label describing when the snapshot is taken, for example
"py3.14 after unit tests". It is echoed in the banner so that consecutive snapshots can be told apart in the CI log.
- mafw.devtools.dependencies.resources.CGROUP_FILE_PROBES: Final[tuple[tuple[str, str], ...]] = (('memory.current', '/sys/fs/cgroup/memory.current'), ('memory.max', '/sys/fs/cgroup/memory.max'), ('memory.events', '/sys/fs/cgroup/memory.events'), ('cpu.stat', '/sys/fs/cgroup/cpu.stat'))
cgroup v2 pseudo-files inspected to report memory and CPU quota usage.
Each entry is a
(label, path)pair. The paths follow the Kubernetes/cgroup v2 layout mounted inside the runner pod. Missing files are reported but never fatal.
- mafw.devtools.dependencies.resources.RESOURCE_SHELL_PROBES: Final[tuple[tuple[str, str], ...]] = (('disk space (df -h)', 'df -h'), ('inodes (df -i)', 'df -i'))
Shell commands used to inspect disk usage, as
(label, command)pairs.