Skip to main content

Module container_removal

Module container_removal 

Source
Expand description

Removed-container bookkeeping for --status (issue #225).

A kept docker container can be removed later (by hand, by an orchestrator, or by start-command’s own cleanup policy). docker inspect then exits 1 with No such object / No such container, which used to be folded into the same None as “docker could not be queried at all”, so --status kept reporting the old containerId as if the container still held its disk.

This module tells the two failures apart and records the removal on the execution record as containerState: removed plus containerRemovedObservedAt. containerId is kept for history.

Constants§

CONTAINER_REMOVED_ENV
Environment variable the detached watcher sets for the finalizer when its own docker rm -f removed the container.
CONTAINER_STATE_REMOVED
containerState of a record whose container no longer exists.

Functions§

attach_container_removal
Attach containerState: removed to a finished detached docker record whose container no longer exists. The container id is preferred over the session name, so a later container that reuses the name is not mistaken for it.
is_docker_not_found
Whether a failed docker inspect answered that the object is unknown: Error: No such object: <name> (docker inspect, Docker 29 prints it lower-case) or Error response from daemon: No such container: <name>. A daemon that cannot be reached (“Cannot connect”, “failed to connect … no such file or directory”) does not match.
mark_container_removed
Set containerState: removed on a record, keeping an earlier observation time when there is one.
persist_container_removal
Persist a removal --status observed, best effort: a read-only query must never fail because the store could not be written.