-
Notifications
You must be signed in to change notification settings - Fork 1.8k
utils: handle ipv6 hosts when splitting URLs #10706
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
WalkthroughThe changes update URL parsing logic to correctly handle IPv6 addresses enclosed in brackets, ensuring that colons within IPv6 literals are not mistaken for port separators. Corresponding unit tests and AWS credentials HTTP provider tests are added to verify correct behavior with IPv6 endpoints. Changes
Sequence Diagram(s)sequenceDiagram
participant TestCase as Test (aws_credentials_http.c)
participant Provider as AWS HTTP Provider
participant Utils as URL Parsing Logic
participant MockHTTP as Mock HTTP Server
TestCase->>Provider: Set AWS_CONTAINER_CREDENTIALS_FULL_URI to IPv6 URL
Provider->>Utils: Parse URL (IPv6 in brackets)
Utils-->>Provider: Return protocol, host, port, URI
Provider->>MockHTTP: GET /iam_credentials/pod1 (IPv6 host)
MockHTTP-->>Provider: Return credentials JSON
Provider-->>TestCase: Provide credentials
TestCase->>Provider: Refresh credentials
Provider->>MockHTTP: GET /iam_credentials/pod1 (again)
MockHTTP-->>Provider: Return new credentials JSON
Provider-->>TestCase: Provide refreshed credentials
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Closes fluent#10699 Signed-off-by: Daniel Moran <[email protected]>
50993f9
to
44d77dd
Compare
{0, "https://fluentbit.io:1234/v", "https", "fluentbit.io", "1234", "/v"}, | ||
{-1, "://", NULL, NULL, NULL, NULL}, | ||
{0, "http://[fd00:ec2::23]/v1/credentials", "http", "fd00:ec2::23", "80", "/v1/credentials"}, | ||
{0, "https://[::192.9.5.5]:1234/v", "https", "::192.9.5.5", "1234", "/v"} |
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.
Self-review: I am not sure here if there will be a problem when actually trying to use the hosts because we stripped out the enclosing []
s. The existing *_copy_host_*
functions were stripping the brackets (or trying to) so I kept the behavior. Would appreciate a sanity-check!
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.
They were trying to strip out the brackets but I suspect without -2 we would end up with URIs ending with ]
and I expect those would have failed.
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.
Agreed, I saw that failure mode before I switched it from -1
to -2
@PettitWesley @edsiper @leonardo-albertovich @fujimotos @koleini (sorry for the spam) do you have an ETA on when you'll be able to review this + the backport PR? Trying to decide if I should give in and enable IRSA on my auto mode cluster or hold out for a bit longer to use pod identity |
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.
I think this is close, going to create a beta image and validate for AWS distribution
return NULL; | ||
} | ||
return flb_sds_create_len(string + pos_init + 1, pos_end - 1); | ||
return flb_sds_create_len(string + pos_init + 1, pos_end - 2); |
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.
for the casual reader, the change from -1 to -2 to remove the bracket from the new substring
Related to fluent#10706
Related to fluent#10706
After more testing in aws/aws-for-fluent-bit#983 (comment), I think that this may be the wrong approach. The bracketing for hostname is was off-by-one but the underlying problem is a bit more subtle. We shouldn't care to remove brackets from the ipv6 URLs and also handle proper skipping of brackets (part of this PR), but low level calls to c-apps (getaddrinfo, etc) need to trim brackets before connection of we run into:
Removing the |
:
s in the host from being interpreted as a port separatorCloses #10699
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
#10707
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit
Bug Fixes
Tests