coreos/rocket — pull request #313 by vcaputo (2014-12-30 23:23:41+00:00)
Title: rkt status: implement status

Simple querying of container status by uuid is provided.

The pid of the container's stage1, an exited boolean, and per-imageid
exit status codes are printed when available.

Container exit synchronization occurs when --wait is specified.

Examples:
Already exited but not yet garbage collected container:

$ rkt status --uuid 32e5c3d4-c851-4c46-bddc-b52c46449523
pid=11219
exited=true
sha256-f9124faae79eb859b27581d9673a2d29a8e394a2685088753264dea276dd7571=0
$

Already exited and "marked" for garbage collection by rkt gc (same as above):

$ rkt status --uuid 32e5c3d4-c851-4c46-bddc-b52c46449523
pid=11219
exited=true
sha256-f9124faae79eb859b27581d9673a2d29a8e394a2685088753264dea276dd7571=0
$

Already exited and actively being discarded by rkt gc (treated as gone):

$ bin/rkt status --uuid 874d5c50-ee5e-4cb9-9b30-c95778398e43
Unable to query status: "874d5c50-ee5e-4cb9-9b30-c95778398e43" is being removed
$

Currently executing container:

$ rkt status --uuid 8b06b7af-7d53-4723-bc0c-fe6e47463fcb
pid=12227
exited=false
$

Waiting on potentially executing container to exit for exit status:

$ time bin/rkt status --uuid ec5df2c6-b5d9-495d-aea0-c2cf5da706c2 --wait
pid=12319
exited=true
sha256-f9124faae79eb859b27581d9673a2d29a8e394a2685088753264dea276dd7571=0

real 0m21.470s <<< note delay before returning
user 0m0.028s
sys 0m0.004s
$

$ time bin/rkt status --uuid ec5df2c6-b5d9-495d-aea0-c2cf5da706c2 --wait
pid=12319
exited=true
sha256-f9124faae79eb859b27581d9673a2d29a8e394a2685088753264dea276dd7571=0

real 0m0.033s <<< note zero delay when already exited
user 0m0.024s
sys 0m0.008s
$