mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 04:36:40 +00:00
distros.sh stops a distro at its budget with `timeout -k 60`: SIGTERM at the deadline, SIGKILL 60 s later. dedicated.sh's cleanup trap then ran the in-container capture under `timeout 1500` (266 s in Baserow#0 of run 40625679270) and the host capture under `timeout 900`, so the SIGKILL always landed mid-capture, the snapshot was never copied out and the rescue-diagnostics artifact was lost. The inner `timeout` also sat in its own process group and outlived the kill, holding the step open. - distros.sh keeps the grace in one place, KILL_GRACE_SECONDS, and exports INFINITO_CI_DISTRO_KILL_EPOCH next to the deadline epoch. - scripts/tests/deploy/utils/rescue_window.sh decides per trap step: past the deadline, the step gets half of the time left until the SIGKILL (at least 1 s) and an end epoch; before it, the nominal timeout and no end epoch. Inside the trap `$?` is 0 on a budget kill, so the deadline epoch is the only reliable signal. - dedicated.sh runs both captures through `timeout --foreground` with that window, keeping them in the trap's process group, and passes the end epoch as RESCUE_DEADLINE. - utils/diagnostics/container.py caps every command at RESCUE_DEADLINE, writes `[skipped: past RESCUE_DEADLINE]` for what no longer fits and hands the deadline to nested captures. Without the variable nothing changes, so the swarm and workspace callers behave as before. -k 60, the distro budget and every timeout-minutes are unchanged. Drill tests replay the trap with the real helper and container.py: a budget kill ends with rc 124 and the snapshot copied out, the old shape ends with rc 137 and nothing copied, an early failure keeps the full capture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shared Utilities (utils/)
This directory contains shared Python helpers used by custom modules and plugins.
Purpose
Use utils/ for reusable code that should not be duplicated across:
library/modules,plugins/action/,plugins/filter/,plugins/lookup/.
Typical shared utilities:
- API clients,
- validation/conversion helpers,
- path and configuration helpers,
- cross-plugin/module domain logic.
- Shared HTTP(S) connection handler for multiple modules.
- Common validation or transformation functions for user input.
- Utility functions for interacting with Docker, LDAP, etc.
- Grouped helper packages such as
utils/domains/for related domain logic.
Design Guidelines
- Keep helpers focused and composable.
- Avoid side effects during import.
- Prefer explicit function/class APIs over implicit globals.
- Keep dependencies minimal so modules/plugins stay lightweight.
Example Import
from utils.domains.primary_domain import get_primary_domain
What Does Not Belong Here
- Standalone executable modules (put in
library/). - Ansible plugin entrypoints (put in
plugins/*).
References
- Module utilities: https://docs.ansible.com/ansible/latest/dev_guide/developing_module_utilities.html
- Plugin development: https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html