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§
- Detached
Finalize Facts - The docker facts the watcher hands over.
- Finalize
Outcome - Outcome of a finalization attempt.
updatedis false when there was nothing to correct (or nothing to correct it on).
Constants§
- END_
TIME_ SOURCE_ DOCKER_ FINISHED_ AT end_timecame fromdocker inspect .State.FinishedAt— the container’s own clock, the only real finish time available.- END_
TIME_ SOURCE_ LOG_ FOOTER end_timecame from the anchoredFinished:linestartitself 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
--helpstays free of it. - WATCHER_
LOST_ CONTAINER exit_reasonof a record whose container exit the watcher never observed: docker had noFinishedAtfor 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_removedsays the watcher’s owndocker rm -fremoved 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], withSTART_INTERNAL_CONTAINER_REMOVED=truewhen the watcher removed the container (issue #225). Always succeeds: see the module docs.