-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(aws): support aws_ca_bundle #5665
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
Conversation
|
Hi @mwmix. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
provider/aws/instrumented_config.go
Outdated
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.
Configuring metrics per provider not a great idea. Please avoid that.
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 agree with you, I've been struggling to find a better implementation. Any insights would be appreciated.
provider/aws/config.go
Outdated
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.
config.WithHTTPClient(extdnshttp.NewInstrumentedClient(AWSHTTPCLIENT)),^ Something simliar
What happens if we simply add WithCustomCABundle, my understanding it could work, even if we wrapping http client
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 tried to come up with a way to do what you suggested before I dived down the middleware rabbit hole. But, I kept hitting road blocks. The closest I could get was this and we get a type error:
func NewInstrumentedAWSClient(next *awshttp.BuildableClient) *awshttp.BuildableClient) {
next.WithTransportOptions(func(transport *http.Transport) {
transport = NewInstrumentedTransport(next)
})
}
The type error is
cannot use next (variable of type *"github.com/aws/aws-sdk-go-v2/aws/transport/http".BuildableClient) as "net/http".RoundTripper value in argument to NewInstrumentedTransport: *"github.com/aws/aws-sdk-go-v2/aws/transport/http".BuildableClient does not implement "net/http".RoundTripper (missing method RoundTrip)
So the WithCustomCABundle would "work" and so does just updating my systems trusted ca list. However, the moment we set AWS_CA_BUNDLE even with the WithCustomCABundle set then we still hit that error. One workaround would be to use WithCustomCABundle pulling the value from AWS_CA_BUNDLE and then unsetting the environment variable so the SDK doesn't use it. But, I imagine that has it's own issues ...
When looking at other projects such as otel and based on my own reading of the documentation it seemed like this was the expected interface for adding this sort of functionality.
I'm not really married to any particular solution and appreciate your feedback. I've been trying my best to minimize the impact of the changes while preserving the existing instrumentation but haven't found any cleaner way around it.
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 do not have access to AWS. If you could reproduce it with kind+localstack or similar, might be able to have a look.
Have you tried WithCustomCABundle?
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.
As well, have you tried for example
config.WithHTTPClient(extdnshttp.NewInstrumentedClient(&http.Client{Transport: transport.NewBuildableClient().GetTransport()})),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 tried WithCustomCABundle() and the error still appears when I try to run with the AWS_CA_BUNDLE defined.
I just also finished testing the last example you gave me above with the same result :(
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.
Gotcha
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.
Just a note about opentelemetry. It's ok to have a middleware support, but still expected to to support RoundTrippers https://github.com/open-telemetry/opentelemetry-go-contrib/blob/caee80916a50f168c7152967dabaefd0c3cd17c0/instrumentation/net/http/otelhttp/transport.go#L26
Basically to be a consistent across multiple libraries. With aws there is no such option, it's quite aws specific
provider/aws/instrumented_config.go
Outdated
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.
Can we keep everything within the existing package sigs.k8s.io/external-dns/pkg/http, unless there’s a circular dependency that prevents it or other valid reason?
Please note that packages named utils are not being approved at this time.
For reference, see this example where a similar utils package was proposed but not accepted: #5189 (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.
Sure, ty for the insight. I'll update the MR appropriately.
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.
Is it possible to reuse this certs or location https://github.com/kubernetes-sigs/external-dns/tree/master/internal/testresources?
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.
Yeah absolutely, I didn't realize you already had some stashed away in the repo! :)
7b1027a to
ae5a1bd
Compare
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.
There should be a simple reason why certificate bundle is not loaded. Hard to say without how-to-reproduce example
provider/aws/config.go
Outdated
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.
As well, have you tried for example
config.WithHTTPClient(extdnshttp.NewInstrumentedClient(&http.Client{Transport: transport.NewBuildableClient().GetTransport()})),|
The WHY is not working is described here https://github.com/aws/aws-sdk-go-v2/blob/f9f7a6bb124a1a7daffc65db40053d97678bd371/config/env_config.go#L174-L189. In principal, AWS sdk instead of Transport should have RoundTripper, as go http library does. Could we add to our instrumenter an option to wrap and return Transport if Middleware is an OK way, but AWS library middleware is just to complex. |
|
Technically, if we passing a Transport Just need to find out how to enhance it with our metrics. |
|
I'm unsure actually. I do get why AWS team done it that way, but not simple to extend. /ok-to-test |
|
/retitle fix(aws): support aws_ca_bundle |
pkg/http/http.go
Outdated
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.
Ideally this should stay. The plan is to wrap it like here
external-dns/pkg/metrics/metrics.go
Line 38 in 789494f
| RegisterMetric.MustRegister(NewGaugeFuncMetric(prometheus.GaugeOpts{ |
external-dns/controller/controller.go
Line 38 in 789494f
| registryErrorsTotal = metrics.NewCounterWithOpts( |
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.
Changing this, may affect kube monitoring as well, which is not desirable.
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 pushed a new commit which refactors the fix to use the common metrics registry. Does that work? Or do we want to split that into a different PR?
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 you have time, would be better to slice PRs.
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.
Okay I've modified this PR so it has what I hope is the minimum set of changes you were hoping for. I'll have another PR out either later tonight / tomorrow which will be branched off this with the other changes I made.
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.
Opened PR #5677 for the metrics refactoring.
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.
The code LGTM.
Like for the previous change on metrics, the latest refactor asked by @ivankatliarchuk should go in its own dedicated PR.
=> Would you please extract the code in pkg/http & pkg/metrics in a dedicated refactor PR ?
90d10ba to
474d1fc
Compare
Yep can do, new PR opened #5717. |
5a6a8b3 to
45c8da8
Compare
provider/aws/instrumented_config.go
Outdated
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 wonder how this works without issues. The package pkg/http depends on pkg/metrics. Interesting, I would expect cyclic dependency
|
/lgtm |
|
It seems like no issues. so lgtm as well /approve |
|
Fixes #5666 |
|
/remove-approve |
45c8da8 to
937be24
Compare
|
Ah I see the issue this isn't using the refactored stuff. I've re-based everything and pushed updates. I can build locally and 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.
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivankatliarchuk The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |

What does it do ?
Fixes an issue when you have the AWS_CA_BUNDLE set and are using the 'aws' provider. The error is as follows:
Motivation
This causes me a ton of headache recently and I was forced to use a Debian based container of the tool as opposed to the scratch based one.
More