Files
docker-cli/cli/command
Sebastiaan van Stijn b642078c87 prevent "docker stats" from hanging if the initial API call fails
When running `docker stats` without a list of containers, `runStats` collects
an initial list of containers. If that API call fails, the error is sent to the
`closeChan`, however, `closeChan` is non-buffered, and nothing is reading the
channel until we received the initial list and start collecting stats.

This patch rewrites the code that gets the initial list of containers to
return the error if the API call fails. The `getContainerList` closure is
also removed and inlined to make the logic somewhat easier to read.

Before this patch, the command would hang without producing output;

    docker stats
    # hangs; no output

With this patch, the error is printed, and the CLI exits:

    docker stats
    Error response from daemon: some error occurred

    echo $?
    1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-20 16:22:11 +01:00
..
2023-12-12 22:30:16 +01:00
2023-12-12 22:30:16 +01:00
2023-12-12 22:30:16 +01:00
2023-12-12 22:30:16 +01:00
2023-12-12 22:30:16 +01:00