Skip to main content

Module detached_finalize

Module detached_finalize 

Source
Expand description

Detached completion finalizer (issue #170).

A detached Docker session outlives the CLI process that started it: the foreground start invocation returns as soon as the container is up, so nobody is left to write the terminal state back into the execution store. The record therefore stayed executing forever, with exitCode: null and endTime: null, and every --status query had to re-derive the outcome from scratch — fabricating endTime with the current time in the process.

The detached completion watcher (see docker_cleanup) now re-invokes the start binary with a hidden flag once the container is gone, handing over the facts it already read out of a single docker inspect. The finalizer is deliberately silent and infallible: it is a short-lived child process on a host whose CLI invocation is long gone, so a bookkeeping failure must never surface as an error in a log the user is reading for the command’s output.

Structs§

DetachedFinalizeFacts
The docker facts the watcher hands over.
FinalizeOutcome
Outcome of a finalization attempt. updated is false when there was nothing to correct (or nothing to correct it on).

Constants§

END_TIME_SOURCE_DOCKER_FINISHED_AT
end_time came from docker inspect .State.FinishedAt — the container’s own clock, the only real finish time available.
END_TIME_SOURCE_LOG_FOOTER
end_time came from the anchored Finished: line start itself wrote.
END_TIME_SOURCE_OBSERVED_AT
No real finish time exists: this is when the end was observed.
INTERNAL_FINALIZE_FLAG
Hidden argument the detached watcher re-invokes this binary with. Not part of the public CLI surface: it is an implementation detail of the watcher, and --help stays free of it.
WATCHER_LOST_CONTAINER
exit_reason of a record whose container exit the watcher never observed: docker had no FinishedAt for it, so neither the exit code nor the end time is a fact (issue #174).

Functions§

build_detached_finalize_snippet
Shell fragment that hands the inspected docker facts to this finalizer.
build_detached_finalize_snippet_with_attempt
finalize_detached_execution
Persist the terminal state of a detached execution.
finalize_detached_execution_with_attempt
finalize_detached_execution_with_removal
Same as finalize_detached_execution_with_attempt; container_removed says the watcher’s own docker rm -f removed the container (issue #225).
reconcile_finalized_record
Reconcile an in-memory record with one the detached watcher already finalized.
run_internal_finalize
Entry point for --internal-finalize-detached-docker <uuid> <exit> <oom> <started> <finished> <error> <running> <cgroup> [attempt], with START_INTERNAL_CONTAINER_REMOVED=true when the watcher removed the container (issue #225). Always succeeds: see the module docs.