Skip to content

Suppress warnings for transient stdin backpressure - #705

Open
sairex53 wants to merge 1 commit into
containers:mainfrom
sairex53:689-ignore-eagain-stdin
Open

sairex53 wants to merge 1 commit into
containers:mainfrom
sairex53:689-ignore-eagain-stdin

Conversation

@sairex53

Copy link
Copy Markdown

Fixes #689.

Writes to the container stdin pipe and socket are nonblocking. When they return EAGAIN or EWOULDBLOCK, the pending bytes remain queued and are retried when the fd becomes writable, so this is expected backpressure rather than a write failure. Avoid logging a warning for those errno values while preserving warnings for other errors.

Add an attach regression test that delays the container's stdin reader, sends an 8 MiB payload, and checks conmon's journal for the spurious warning.

Testing:

  • make -j2 (passed)
  • The Bats regression is added but was not run locally because this host lacks bats and socat; CI will run it.

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
@sairex53
sairex53 force-pushed the 689-ignore-eagain-stdin branch from 315f805 to 5b13f6b Compare October 18, 2026 07:48
Comment thread test/test_helper.bash
}

# Create a script in the container rootfs for a test.
create_test_script() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_test_script and update_container_args are moved here, but the original definitions are still in test/06-priority-parsing.bats (lines 22 and 31), so they are now duplicated (06 silently overrides these). Please remove them from 06, the same way skip_if_no_journald was.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and make it a separate cleanup commit (perhaps the first one)

Comment thread test/07-attach.bats

create_test_script "slow_stdin.sh" '#!/bin/sh
sleep 2
cat >/dev/null'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of discarding the input, consider having the container count it (e.g. wc -c) and then checking that the log contains 8388608. That would also verify the main claim behind the fix: on EAGAIN the bytes are retried and nothing is lost.

Comment thread test/07-attach.bats
wait_for_runtime_status "$CTR_ID" running

# Keep the container stdin pipe full while its reader is sleeping.
head -c 8388608 /dev/zero | socat -u STDIN "UNIX:${ATTACH_PATH},socktype=5"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 8 MiB is much more than needed to fill a pipe (64 KiB by default); something like 1 MiB should be enough and makes the test faster.

Comment thread test/07-attach.bats

local journal_output
journal_output=$(get_conmon_journal_output "$CONMON_PID")
if [[ "$journal_output" == *"Failed to write to fd container stdin"* ]]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a negative check, so it passes vacuously if the journal returns nothing for this conmon (journald lag, filtering mismatch, etc.), and the test would not catch a regression. Please first assert that journal_output is non-empty (conmon runs with --log-level trace --syslog, so it always logs something), and then use the existing helper for the actual check, e.g.

[ -n "$journal_output" ] || die "no journal output for conmon $CONMON_PID"
assert "$journal_output" !~ "Failed to write to fd container stdin"

@TDnorthgarden

Copy link
Copy Markdown
Contributor

Hi @sairex53 — it looks like this PR may have gone quiet while waiting for the review feedback to be addressed. The approach looks right to me, so I went ahead and prepared the changes @kolyshkin requested:

  1. removed the create_test_script / update_container_args definitions left behind in test/06-priority-parsing.bats (the helpers now live only in test_helper.bash), split into a separate cleanup commit
  2. the container now counts its input (wc -c) and the test asserts the exact byte count, so the regression also catches input loss on EAGAIN retry
  3. payload reduced from 8 MiB to 1 MiB (the pipe buffer is 64 KiB)
  4. the negative check now requires non-empty journal output first, and uses the assert ... !~ helper

Verified locally: the new test fails on the unfixed binary and passes with the fix; 07-attach and 06-priority-parsing suites are green. If you'd like to keep driving your PR, the branch and patch are yours to use. Otherwise I'll open a follow-up PR referencing this one, with your Signed-off-by preserved. Either way, thanks for the fix! @kolyshkin, happy to push it for your review if the original
author is away.

@kolyshkin

Copy link
Copy Markdown
Collaborator

@TDnorthgarden feel free to open a carry PR!

@TDnorthgarden

Copy link
Copy Markdown
Contributor

@TDnorthgarden feel free to open a carry PR!

Thanks @kolyshkin! Carry PR opened: #715 — @sairex53's Signed-off-by is preserved in both commits, and all your review comments are
addressed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conn_sock.c: 'Failed to write container stdin' is logged on every EAGAIN, flooding the journal for slow stdin consumers

3 participants