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

Fix HTTP/2 Upgrade flow for requests with content (post/put/...) #7105

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

reta
Copy link
Collaborator

@reta reta commented Apr 11, 2023

Description

[Describe what this change achieves]

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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.

final HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(
sourceCodec,
upgradeCodecFactory,
handlingSettings.getMaxContentLength()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Found this one while prototyping #3000: by default, Netty assumes the upgrade is initiated by GET requests, but in case of OpenSearch, that is not necessarily the case.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

return false; // enable http
}

public void testThatNettyHttpServerSupportsHttp2() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

Why not make the post operation another test case in Netty4Http2IT as opposed to creating a separate test class?

Copy link
Collaborator Author

@reta reta Apr 11, 2023

Choose a reason for hiding this comment

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

Because we need "clean state" when no upgrade happened yet, if we bundle both tests cases, the server side upgrade flow would be already exercised by one of the test cases.

Copy link
Member

Choose a reason for hiding this comment

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

Scope.TEST doesn't give you that clean state on each test method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm ... that's interesting, it should but I have test run issues ... let me check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}
}

private void assertOpaqueIdsInAnyOrder(Collection<String> opaqueIds) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you could replace this whole method with assertThat(opaqueIds, equalTo(List.of("0")));, no? The matcher should give a good error message by default.

Copy link
Member

Choose a reason for hiding this comment

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

or even assertThat(opaqueIds, contains("0"));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, thanks!

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Andriy Redko <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.repositories.azure.AzureBlobContainerRetriesTests.testReadBlobWithRetries

Signed-off-by: Andriy Redko <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2023

Codecov Report

Merging #7105 (af69e95) into main (3ba333b) will decrease coverage by 0.18%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main    #7105      +/-   ##
============================================
- Coverage     70.77%   70.60%   -0.18%     
+ Complexity    59367    59226     -141     
============================================
  Files          4825     4825              
  Lines        284369   284370       +1     
  Branches      41021    41021              
============================================
- Hits         201263   200780     -483     
- Misses        66603    67014     +411     
- Partials      16503    16576      +73     
Impacted Files Coverage Δ
...nsearch/http/netty4/Netty4HttpServerTransport.java 56.08% <100.00%> (+0.23%) ⬆️

... and 500 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

}
}

private void assertOpaqueIdsInAnyOrder(int expected, Collection<String> opaqueIds) {
// check if opaque ids are present in any order, since for HTTP/2 we use streaming (no head of line blocking)
// and responses may come back at any order
int i = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think this local variable is unused

}
}

private void assertOpaqueIdsInAnyOrder(int expected, Collection<String> opaqueIds) {
// check if opaque ids are present in any order, since for HTTP/2 we use streaming (no head of line blocking)
// and responses may come back at any order
int i = 0;
String msg = String.format(Locale.ROOT, "Expected list of opaque ids to be in any order, got [%s]", opaqueIds);
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but I think you can remove this because assertThat will generate a good error message by default

import static org.hamcrest.Matchers.hasSize;

@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1)
public class Netty4Http2PostIT extends OpenSearchNetty4IntegTestCase {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be removed now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh sure, git played with me here :(

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Andriy Redko <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.index.IndexServiceTests.testAsyncTranslogTrimTaskOnClosedIndex

@reta reta merged commit a15475a into opensearch-project:main Apr 11, 2023
austintlee pushed a commit to austintlee/OpenSearch that referenced this pull request Apr 28, 2023
…nsearch-project#7105)

* Fix HTTP/2 Upgrade flow for requests with content (post/put/...)

Signed-off-by: Andriy Redko <[email protected]>

* Address code review comments

Signed-off-by: Andriy Redko <[email protected]>

* Address code review comments

Signed-off-by: Andriy Redko <[email protected]>

* Address code review comments

Signed-off-by: Andriy Redko <[email protected]>

---------

Signed-off-by: Andriy Redko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants