Skip to main content

Module drain

Module drain 

Source
Expand description

Bounding the output which gets forwarded after the process exited.

Structsยง

Drain ๐Ÿ”’
Bounds forwarding the output after the process exited.
Lag ๐Ÿ”’
Logs an attach client which falls behind the output once until it caught up again, like LogErrors. A client which stays too slow skips messages again every time the channel filled up, which would log a warning for every one of its capacity of messages otherwise.

Enumsยง

Logging ๐Ÿ”’
What Drain::recv_logging ended with.

Constantsยง

DRAIN_MAX_LOG_WAIT ๐Ÿ”’
Upper bound for the time the exit files and the attach drains wait for the log drivers to take the output after the process exited, which does not count as a pause of the output, see SharedContainerAttach::logging and Drain::recv_attach, and for the read loops to end once stopped and the log to sync, see ReapableChild::finish_output. A log driver which is slow, like a journal which takes only part of every chunk in time, or which hangs, like a log file on a stuck disk, must not keep the exit from being reported for minutes.
DRAIN_MAX_MESSAGES ๐Ÿ”’
Upper bound for the messages forwarded per drain after the process exited. The output written before the exit is at most what the channels, the STDIO_CHANNEL_SIZE of the stdio ones or the OUTPUT_CHANNEL_SIZE of the attach broadcast, and the pipe buffers hold. With the default pipe-max-size of 1 MiB in 8 KiB reads, that is 128 messages per pipe, and small writes read one by one do not fill a pipe of that size either, so this is well above. It is a heuristic though, a process with CAP_SYS_RESOURCE can grow its pipes further. More output stems from a grandchild which keeps the pipe open and writing, which would otherwise keep the drain going forever.
DRAIN_MAX_WAIT ๐Ÿ”’
Upper bound for the time a drain waits for output after the process exited in total. A grandchild which keeps writing just often enough for DRAIN_TIMEOUT would keep it going for minutes otherwise. Only the waiting counts, not the forwarding, so a slow client still gets the output which was there already.
DRAIN_TIMEOUT ๐Ÿ”’
Upper bound for waiting on the next output after the process exited. The read loops may still be draining the pipes when the exit is observed, they signal the end with Message::Done. The timeout only kicks in if that never arrives, for example because a grandchild keeps the pipe open.