cmd/containerd-shim-runhcs-v1: prevent zombie shims by adding timeout to stdin read#2824
cmd/containerd-shim-runhcs-v1: prevent zombie shims by adding timeout to stdin read#2824HarshalPatel1972 wants to merge 1 commit into
Conversation
… to stdin read When the containerd daemon restarts or exits unexpectedly on Windows, the named pipe write handles may be inherited or fail to immediately broadcast an EOF. Because io.ReadAll does not natively respect context.Context, the runhcs shim blocks indefinitely waiting for data, leaking the process and blocking network ports. This introduces a background monitor with a 5-second timeout that explicitly closes os.Stdin if the read takes too long. This forcefully aborts the blocking I/O read, allowing the shim to detect the daemon disconnection and terminate gracefully. Signed-off-by: Harshal Patel <hp842484@gmail.com>
|
Thanks for this, but I think the change is based on a misdiagnosis and should not merge. Shim options aren't a live stream; containerd marshals them into a fixed buffer at process start and pipes them in — cmd.Stdin = bytes.NewReader(d) // d = proto.Marshal(opts)
The change is also risky: force-closing Real zombie-shim cases are on the serving side (ttrpc shutdown, log-pipe |
cmd/containerd-shim-runhcs-v1: prevent zombie shims by adding timeout to stdin read
When the containerd daemon restarts or exits unexpectedly on Windows, the
named pipe write handles may be inherited or fail to immediately broadcast
an EOF. Because io.ReadAll does not natively respect context.Context,
the runhcs shim blocks indefinitely waiting for data, leaking the process
and blocking network ports.
This introduces a background monitor with a 5-second timeout that explicitly
closes os.Stdin if the read takes too long. This forcefully aborts the blocking
I/O read, allowing the shim to detect the daemon disconnection and
terminate gracefully.
Signed-off-by: Harshal Patel hp842484@gmail.com