Skip to content
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

Migrate to Apache HttpClient / Core 5.x #2166

Merged
merged 38 commits into from
Oct 18, 2022

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Oct 13, 2022

Signed-off-by: Craig Perkins cwperx@amazon.com

Description

This PR contains changes related to migration to Apache HttpClient and Core 5.x from 4.x with changes that fix build failures. The security plugin needs to retain support for v4 http client for SAML because of the class SamlHTTPMetadataResolver which extends OpenSAML and OpenSAML has a dependency on v4.

CI will fail until new artifacts for common-utils are available after this PR is merged - opensearch-project/common-utils#281

I updated build.gradle to keep opensearch and common-utils in sync, this can be changed back if needed but to get CI working for this PR it needs to reference the latest distribution build.

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)

Enhancement

Issues Resolved

Related to opensearch-project/OpenSearch#4256, security plugin needs to upgrade as well

Addresses: 2165

Testing

CI

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

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.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
…s needed by OpenSAML

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
…sedSSLConfiguratorTest to v4

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
@cwperks cwperks changed the title Apache client5 Migrate to Apache HttpClient / Core 5.x Oct 13, 2022
requestConfig = RequestConfig.copy(requestConfig).setLocalAddress(inetAddress).build();
}
}
// TODO Can this be removed?
Copy link
Member

Choose a reason for hiding this comment

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

If this is unused, yes remove it.

Copy link
Member

Choose a reason for hiding this comment

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

And we can do this for any unused public members under src/integrationTest

build.gradle Outdated
@@ -394,7 +398,7 @@ dependencies {
testImplementation 'org.springframework:spring-beans:5.3.20'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation "org.opensearch:common-utils:${common_utils_version}"
testImplementation "org.opensearch:common-utils:${opensearch_version}"
Copy link
Member

Choose a reason for hiding this comment

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

Could not resolve org.opensearch:common-utils:3.0.0-SNAPSHOT

We need this for the integration test dependenices? It seems like we might need to hold off on this change until we can update common-utils first :/

Copy link
Member Author

Choose a reason for hiding this comment

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

When new artifacts are available I will re-trigger the CI

Copy link
Member

Choose a reason for hiding this comment

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

org.opensearch.commons.rest.SecureRestClientBuilder fails as it is not compatible with v5. Common-utils has a open PR: opensearch-project/common-utils#281 out to address this

cwperks and others added 11 commits October 13, 2022 14:04
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Update remaining tests to use http client 5
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
httpClientBuilder.setConnectionManager(cm);
// Attempt to resolve org.apache.hc.core5.http.ParseException: Invalid protocol version
httpClientBuilder.setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@cwperks I will look at this one, we should good with HTTP/2 at this point

@cwperks
Copy link
Member Author

cwperks commented Oct 18, 2022

CI is now green! :)

@cwperks great one, I think I can close #2172 ?

Yes, unless this PR missed the mark on the migration somewhere. I was looking at your PR in core (opensearch-project/OpenSearch#4459) and the migration guide provided by apache to find the right analogs in v5 to migrate to.

Please push directly on this branch with any changes you think are appropriate. I was not able to resolve the org.apache.hc.core5.http.ParseException: Invalid protocol version errors with Http 1.1 / Http2

…bhookSink

Signed-off-by: Craig Perkins <cwperx@amazon.com>
@reta
Copy link
Collaborator

reta commented Oct 18, 2022

Please push directly on this branch with any changes you think are appropriate. I was not able to resolve the org.apache.hc.core5.http.ParseException: Invalid protocol version errors with Http 1.1 / Http2

I will take a look at it, could you please add me as collaborator to your branch (I think I do not have permissions to push there), thank you.

@cwperks
Copy link
Member Author

cwperks commented Oct 18, 2022

@reta I just added you as a collaborator - you should have received an invite.

peternied
peternied previously approved these changes Oct 18, 2022
@peternied
Copy link
Member

There are some follow-ups but I'd rather do that with a building main - great work @cwperks

@reta
Copy link
Collaborator

reta commented Oct 18, 2022

There are some follow-ups but I'd rather do that with a building main - great work @cwperks

@peternied fix on the way, hold on please

…rsion

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
@reta
Copy link
Collaborator

reta commented Oct 18, 2022

@peternied all set. @cwperks great work!

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

Ty @reta and @cwperks !!

@DarshitChanpura DarshitChanpura merged commit 41d68cc into opensearch-project:main Oct 18, 2022
@cwperks
Copy link
Member Author

cwperks commented Oct 18, 2022

Thank you for the help @reta!

stephen-crawford pushed a commit to stephen-crawford/security that referenced this pull request Nov 10, 2022
This PR contains changes related to migration to Apache HttpClient and Core 5.x from 4.x with changes that fix build failures. The security plugin needs to retain support for v4 http client for SAML because of the class SamlHTTPMetadataResolver which extends OpenSAML and OpenSAML has a dependency on v4.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
@cwperks cwperks mentioned this pull request Jul 3, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants