Skip to content

fluentd: add write timeout log option #49911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025

Conversation

aaithal
Copy link
Contributor

@aaithal aaithal commented May 2, 2025

Added support for fluentd-write-timeout configuration option in the fluentd logger to prevent indefinite blocking when downstream connections become unhealthy. This allows fluentd to abandon unresponsive connections after a specified duration instead of being blocked forever.

Key changes:

  • Added new writeTimeoutKey configuration option
  • Implemented duration parsing and validation
  • Added unit tests to verify timeout behavior with unresponsive server
  • Default timeout remains 0 (no timeout) for backward compatibility

- What I did
Modified fluentd logdriver code to expose a new log option. The log option can be used to specify write timeouts.

- How I did it
The code change exposes the existing config to specify a write timeout value for writes to fluentd server.

- How to verify it
Added a unit test, which fails when the timeout is not specified. The test succeeds when a timeout value is specified.

- Human readable description for the release notes

Add a new log option for fluentd log driver (`fluentd-write-timeout`), which enables specifying write timeouts for fluentd connections.

Copy link
Contributor

@austinvazquez austinvazquez left a comment

Choose a reason for hiding this comment

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

+1, thanks for adding the tests.

@austinvazquez austinvazquez added this to the 28.2.0 milestone May 3, 2025
@aaithal aaithal force-pushed the fluentd-write-timeout branch 2 times, most recently from c129735 to fc79f13 Compare May 5, 2025 19:26
@austinvazquez austinvazquez added area/logging kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels May 5, 2025
@aaithal aaithal force-pushed the fluentd-write-timeout branch from fc79f13 to 880de67 Compare May 5, 2025 21:24
@thompson-shaun thompson-shaun moved this from Up next to Complete in Maintainer spotlight May 8, 2025
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

thanks! overall looking good; I left some nits and suggestions, but let me know what you think!

assert.NilError(t, err, "unable to create listener for socket %s", socketFile)
defer l.Close()

ctx, cancel := context.WithCancel(context.Background())
Copy link
Member

Choose a reason for hiding this comment

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

I was trying the test with the option disabled, and that caused it (expectedly) to hang forever; perhaps we should add a timeout here .. just in case?

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, sounds good.

Comment on lines 249 to 250
return config, errors.Wrapf(err, "invalid value for %s: value must be a duration", writeTimeoutKey)

Copy link
Member

Choose a reason for hiding this comment

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

Stray empty line here

@aaithal
Copy link
Contributor Author

aaithal commented May 9, 2025

Thanks for reviewing this and for the comments. I can address a bulk of these and post an update.

@thaJeztah
Copy link
Member

Thanks! Yes, give me a ping when you had time to do so; when doing so, please amend the commit (squashed); no need to keep them as separate commits ❤️

@aaithal aaithal force-pushed the fluentd-write-timeout branch from 880de67 to 18b8834 Compare May 9, 2025 17:16
@aaithal aaithal force-pushed the fluentd-write-timeout branch from 18b8834 to db52f6b Compare May 9, 2025 18:27
Currently, there's no mechanism to specify a write timeout value for
fluentd connections. This means that writes can forever be blocked if
the downstream connections is unhealthy. This commit makes this value
configurable via a new fluentd log option called "fluentd-write-timeout".

Signed-off-by: Anirudh Aithal <[email protected]>
@aaithal aaithal force-pushed the fluentd-write-timeout branch from db52f6b to 7dae7c5 Compare May 9, 2025 19:32
@aaithal
Copy link
Contributor Author

aaithal commented May 9, 2025

I think I've addressed all of the comments with this change: https://github.com/moby/moby/compare/db52f6b42724419a5f2140c740d5c87eae8f4534..7dae7c54dde81951330170c7678deea350b1d2b8. Can you please take another look @thaJeztah ? Thanks in advance!

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah thaJeztah merged commit 7979b3d into moby:master May 10, 2025
141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging docs/revisit impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/2-code-review
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

5 participants