-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Support IPv6 bind addresses in http_server helper #5239
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
base: master
Are you sure you want to change the base?
Conversation
Fixes URI::InvalidURIError when binding to IPv6 addresses like '::' or '::1'. The http_server helper was generating invalid URIs such as 'http://:::24231' instead of the RFC 3986 compliant 'http://[::]:24231'. Changes: - Wrap IPv6 addresses in brackets when constructing URIs - Add unit tests for IPv6 localhost (::1) and wildcard (::) binding - Update CHANGELOG.md This bug affected all Fluentd versions including v1.19.1 and caused crashes when attempting to bind HTTP servers to IPv6 addresses in dual-stack environments. Resolves: Invalid URI generation for IPv6 bind addresses Signed-off-by: Jesse Awan <jesse.awan@sap.com>
a279091 to
eb72e2a
Compare
|
Could a maintainer please add the |
- Updated server.rb to check if IPv6 addresses are already bracketed - Added tests for pre-bracketed addresses ([::1] and [::]) - Improved ipv6_enabled? helper to verify both binding and resolution - Updated CHANGELOG to document pre-bracketed address handling Signed-off-by: Jesse Awan <jesse.awan@sap.com>
|
@Watson1978 Same issue I encountered within a plugin as well here : |
Signed-off-by: Jesse Awan <jesse.awan@sap.com>
bca5979 to
77b380a
Compare
|
@I501307 Seems it fails the test in CI. Can you take a look at it? |
Signed-off-by: Jesse Awan <jesse.awan@sap.com>
35a521a to
22e03d2
Compare
Root Cause: The Fix (2 parts): server.rb - Normalize addresses on initialization
test_http_server_helper.rb - Replace flaky binding tests Before: Tests tried to bind to IPv6 addresses → failed on CI due to IPv6 networking issues All 19 http_server tests pass (0 errors, 0 failures) |
@Watson1978 The Windows failures are unrelated to this PR - they're in All http_server_helper tests pass on all platforms. Can a maintainer re-run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @I501307 !!
If you afford to write, it might be safer to write with conditional networking test case additionally.
test ... do
omit "" unless ipv6_enabled?
...
end
- Rename addr_display to ip_literal per RFC 3986 terminology - Move ipv6_enabled? helper to test/helper.rb for reusability - Improve IPv6 detection with proper socket binding and address resolution checks Signed-off-by: Jesse Awan <jesse.awan@sap.com>
b703cbd to
f6d21ff
Compare
@kenhys Done! I've renamed the variable to ip_literal and moved ipv6_enabled? to test/helper.rb with improved IPv6 detection logic. Thanks for the review feedback! |
Watson1978
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍🏻
|
I've tried to fix load error of |
ah great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After: Tests only validate formatting logic → no networking required, works everywhere
Verified locally:
Thanks!
It works great without network, but if plugin helper implementation was changed (in the future), also
need to follow test code too.
If we forgot to follow (it might be accidentally happen), it becomes meaningless test cases there.
So I have concern about extracting internal logic directly to test code.
What do you think? @Watson1978
Sorry, I didn't get to look closely at the test code. Indeed. It should not only test the logic itself. |
Signed-off-by: Jesse Awan <jesse.awan@sap.com>
Signed-off-by: Jesse Awan <jesse.awan@sap.com>
Integration tests are now added https://github.com/fluent/fluentd/pull/5239/changes#diff-0733209104ce038bd67b2898b481ab3b6ff2634063b71948ae8a230bb3d5bcf3R23-R29 🌻 |
|
|
@kenhys Please let me know if more tests are required. |
… tests Signed-off-by: Jesse Awan <jesse.awan@sap.com>
0280d82 to
046cc25
Compare
Watson1978
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
|
@kenhys we good to go 🚀 |
| end | ||
| end | ||
|
|
||
| test 'http_server can bind and serve on IPv6 loopback ::1' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Could you use data(...) test pattern to reduce redundant test code? (something like)
data(
'ipv6 loopback test' => [:ipv6_loopback_test, '::1'],
'ipv6 any test' => [:ipv6_any_test, '::']
...
)
test 'http_server can bind and serve on IPv6 address' do |test_case, addr|
...
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If above fix was done, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah 🌻. Now tests look better
1b21008
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can trigger the tests and we are gucci.
Reduce code duplication by combining three separate IPv6 test methods into a single parametrized test using the data() pattern as suggested by reviewer. Signed-off-by: Jesse Awan <jesse.awan@sap.com>
Which issue(s) this PR fixes:
Fixes # (if there's an issue, or remove this line)
What this PR does / why we need it:
Fixes URI::InvalidURIError when binding to IPv6 addresses. The http_server
helper was generating invalid URIs like 'http://:::24231' instead of the
RFC 3986 compliant 'http://[::]:24231'.
Release Note:
http_server helper: Fix IPv6 bind address support