-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support opensearch-ruby 4.0 #47
base: main
Are you sure you want to change the base?
Conversation
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.
First, thanks for picking this up!
So, this replaces the transport in the subclassed client? I think we should not rely on assigning @transport
. I'll merge this once we're done with the 3.x line as it makes things work.
As a next step however I think we should revisit this approach. My first idea was to expose transport
as a client option in the 4.0 opensearch-ruby and getting rid of Sigv4Client
altogether. Users would instantiate a Sigv4Transport
.
But IMO this is wrong too. A sigv4 signer is about request signing. I think users want to pass it as an auth:
parameter, and the opensearch-ruby library should support basic auth, sigv4, and others this way. WDYT?
end | ||
# rubocop:enable Lint/MissingSuper |
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 this actually intended to be missing super
?
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.
Yes. I don't want the superclass to meaninglessly instantiate a hard-coded transport
, that will be overwritten soon after.
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.
Makes sense, this "interface" is borked, see my comment above for what I think we should do here. LMK what you think!
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.
@dblock does adding sigv4 as an auth option in opensearch-ruby
basically move this feature back into opensearch-ruby
? I couldn't find the discussion where we decided to move sigv4 out the core library but I remember we extracted sigv4 out of opensearch-ruby
because sigv4 is a propriety auth method owned by Amazon, and as an opensource project we do not want any favoritism by including Amazon's sigv4 and its dependencies in opensearch-ruby
gem.
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.
does adding sigv4 as an auth option in opensearch-ruby basically move this feature back into opensearch-ruby?
it would but that's not what I am proposing
I am proposing adding auth: [something that can be called or intercept perform_request]
. The client doesn't need to know what that something is, just support an interface.
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. I've created a separated issue for that :)
My initial idea was quite similar, and what I was actually trying to do was something like this: signer = Aws::Sigv4::Signer.new(...)
transport = OpenSearch::Transport::HTTP::Faraday.new(
url: 'http://localhost:9200',
options: {
headers: { 'Content-Type' => 'application/json' },
transport_options: {
ssl: { verify: false }
}
}
)
sigv4_signing_transport_decorator = OpenSearch::Aws::Transport::Transport::Sigv4SigningTransportDecorator.new(transport, signer)
client = OpenSearch::Client.new({ transport: sigv4_signing_transport_decorator }) This decorator simply receives |
@issei-m It's quite unusual to subclass a transport for the purposes of signing requests, try to change the implementation to support callbacks that allow for adding headers instead? |
The solution that @issei-m has here makes sense! It makes this lib work with
Instead of us asking the user every bit of auth info to perform a sigv4 request, we delegate this to the official Sigv4 gem, as the user has to provide an instance of the |
The decorator approach described here is a bit too complicated to use, IMO. It requires the user to know the implementation details of the transport layer and create an instance of |
This looks good to me. Just need to rebase and update the change log. I don't think this will introduce breaking changes and we can release this as a minor version? What do yall thing? |
I would add CI with opensearch-ruby 3.x and 4.x to be sure. |
@nhtruong Thanks for your review and approval. You mean we can go with this approach for both opensearch-ruby 3.x and 4.x? If so, I need to reintroduce the |
as opensearch-ruby@4.0.0 dropped them Signed-off-by: Issei.M <issei.m7@gmail.com>
Signed-off-by: Issei.M <issei.m7@gmail.com>
Signed-off-by: Issei.M <issei.m7@gmail.com>
Signed-off-by: Issei.M <issei.m7@gmail.com>
@issei-m the cc @dblock |
@nhtruong IMPO, mixing the client options with the hash that holds the OpenSearch server options is confusing. If breaking changes are allowed, it might be worth considering a different approach (such as nesting them under Also, since there is already |
I don't think I'll come up with a PR for OpenSearch Ruby Beta.2 soon that will move this feature into the client_options while instantiating the client, instead of the user passing this flag in every API method call. Then with version 4, Sigv4 and other wrappers wont have to worry about excluding the |
Signed-off-by: Issei.M <issei.m7@gmail.com>
@nhtruong Ah, it looks like I misunderstood |
Description
As while discussions in this PR, we figured out the upcoming
opensearch-ruby
broken compatibility a bit but makes our library completely being no longer working.So this PR resolves the issue.
I haven't yet tested on an actual OpenSearch cluster.
Issues Resolved
n/a
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.