Expose container registry for centralized cleanup #25

Open
opened 2025-11-19 20:50:20 +00:00 by glenux · 0 comments
Owner

Summary

  • Provide a shared registry that maps logical container names/engine pairs to running processes so cleanup can be coordinated.
  • Allow ProcessManager and runners to sweep the registry on shutdown to remove dangling docker/podman workloads.

Current behavior

ProcessManager in src/process_manager.cr only tracks OS process IDs and has no awareness of the container that each subprocess created. When a docker/podman child dies unexpectedly or the CLI exits before the child is gone, there is no metadata to call engine-specific cleanup helpers, so containers continue running until the operator intervenes.

Desired behavior

  • Introduce APIs to register and unregister container metadata (name, engine type) alongside tracked processes.
  • Extend the at_exit handler to iterate over registry entries and call the appropriate engine cleanup helpers so containers are killed/removed reliably.
  • Update container/build runners to register their containers and rely on the registry during normal exits, signal handling, and crashes.

Technical notes

  • Store the registry inside ProcessManager or a new helper under DocMachine::Container, and guard it with a mutex so concurrent runners stay safe.
  • Entries should tolerate engines that already shut down and log when cleanup isn't needed.
  • This work implements AUDIT-2025-014 follow-up actions and enables future features that need centralized cleanup orchestration.

Local task: 11aa04

## Summary - Provide a shared registry that maps logical container names/engine pairs to running processes so cleanup can be coordinated. - Allow ProcessManager and runners to sweep the registry on shutdown to remove dangling docker/podman workloads. ## Current behavior ProcessManager in `src/process_manager.cr` only tracks OS process IDs and has no awareness of the container that each subprocess created. When a docker/podman child dies unexpectedly or the CLI exits before the child is gone, there is no metadata to call engine-specific cleanup helpers, so containers continue running until the operator intervenes. ## Desired behavior - Introduce APIs to register and unregister container metadata (name, engine type) alongside tracked processes. - Extend the `at_exit` handler to iterate over registry entries and call the appropriate engine cleanup helpers so containers are killed/removed reliably. - Update container/build runners to register their containers and rely on the registry during normal exits, signal handling, and crashes. ## Technical notes - Store the registry inside ProcessManager or a new helper under `DocMachine::Container`, and guard it with a mutex so concurrent runners stay safe. - Entries should tolerate engines that already shut down and log when cleanup isn't needed. - This work implements AUDIT-2025-014 follow-up actions and enables future features that need centralized cleanup orchestration. Local task: 11aa04
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: glenux/docmachine-cli#25
No description provided.