Backport(v1.19): test_fluentd: read until EOF in assert_fluentd_fails_to_start (#5447) - #5453
Merged
Merged
Conversation
**Which issue(s) this PR fixes**:
Fixes #
**What this PR does / why we need it**:
Gating the read loop on `process_exist?(pid)` is racy: fluentd can write
its final error line and exit right after `eager_read` drains the pipe,
so the loop exits (process gone) before that last line is read. The
error message is then missing from `stdio_buf` and the assertion fails
even though fluentd did fail to start as expected.
This showed up as a flaky failure of "fails to launch fluentd if
specified root path is invalid path for directory": the captured output
ended at "bundler: failed to load command:" without the following "non
directory entry exists:" line.
Loop until the pipe reaches EOF (the write-end is closed when the
process exits) instead, so the remaining buffered output is always
drained. The success case still breaks early once the worker is running,
and hangs are still caught by the outer `waiting(timeout)`. This mirrors
the existing EOF handling in `assert_log_matches`.
This PR will fix following error:
```
4) Failure: test: fails to launch fluentd if specified root path is invalid path for directory(TestFluentdCommand::with system configuration about root directory):
fluentd failed to start, without specified regular expressions:
2026-07-19 09:09:44 +0000 [info]: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2026-07-19 09:09:44 +0000 [info]: parsing config file is succeeded path="/Users/runner/work/fluentd/fluentd/test/command/../tmp/commandfluentd/ce6c61934634f7909ab7/existing_root_dir.conf"
2026-07-19 09:09:44 +0000 [info]: inaccessible include directory was specified path="/etc/fluent/conf.d"
2026-07-19 09:09:44 +0000 [info]: gem 'fluentd' version '1.19.0'
bundler: failed to load command: /Users/runner/work/fluentd/fluentd/bin/fluentd (/Users/runner/work/fluentd/fluentd/bin/fluentd)
.
<false> is not true.
/Users/runner/work/fluentd/fluentd/test/command/test_fluentd.rb:271:in `assert_fluentd_fails_to_start'
/Users/runner/work/fluentd/fluentd/test/command/test_fluentd.rb:378:in `block (2 levels) in <class:TestFluentdCommand>'
375: end
376: conf_path = create_conf_file('existing_root_dir.conf', @conf)
377:
=> 378: assert_fluentd_fails_to_start(
379: create_cmdline(conf_path),
380: "non directory entry exists:#{@root_path}",
381: )
```
Ref.
https://github.com/fluent/fluentd/actions/runs/29680404414/job/88175417915?pr=5446#step:6:5364
**Docs Changes**:
N/A
**Release Note**:
N/A
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Watson1978
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Backport #5447
Fixes #
What this PR does / why we need it:
Gating the read loop on
process_exist?(pid)is racy: fluentd can write its final error line and exit right aftereager_readdrains the pipe, so the loop exits (process gone) before that last line is read. The error message is then missing fromstdio_bufand the assertion fails even though fluentd did fail to start as expected.This showed up as a flaky failure of "fails to launch fluentd if specified root path is invalid path for directory": the captured output ended at "bundler: failed to load command:" without the following "non directory entry exists:" line.
Loop until the pipe reaches EOF (the write-end is closed when the process exits) instead, so the remaining buffered output is always drained. The success case still breaks early once the worker is running, and hangs are still caught by the outer
waiting(timeout). This mirrors the existing EOF handling inassert_log_matches.This PR will fix following error:
Ref. https://github.com/fluent/fluentd/actions/runs/29680404414/job/88175417915?pr=5446#step:6:5364
Docs Changes:
N/A
Release Note:
N/A