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

restore thread context before running action listener #1418

Merged
merged 1 commit into from
Oct 3, 2023

Conversation

ylwu-amzn
Copy link
Collaborator

Description

We see reindex will throw error "wrong user in reader context". That's because after stashing thread context, the user info will be gone. Security plugin will recheck user info when reindex, then throw this error. We should restore thread context before running action listener.

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

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: Yaliang Wu <ylwu@amazon.com>
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 00:15 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 00:15 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 00:15 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 00:15 — with GitHub Actions Inactive
@@ -225,14 +225,14 @@ void registerModel(ActionListener<MLRegisterModelResponse> listener) throws Inte
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
modelGroup.toXContent(builder, ToXContent.EMPTY_PARAMS);
createModelGroupRequest.source(builder);
client.index(createModelGroupRequest, ActionListener.wrap(r -> {
client.index(createModelGroupRequest, ActionListener.runBefore(ActionListener.wrap(r -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be we should add a similar comment in the code also what you have in the PR?

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #1418 (119db8f) into 2.9 (40b40e3) will increase coverage by 0.03%.
Report is 1 commits behind head on 2.9.
The diff coverage is 67.08%.

@@             Coverage Diff              @@
##                2.9    #1418      +/-   ##
============================================
+ Coverage     78.72%   78.76%   +0.03%     
- Complexity     2140     2153      +13     
============================================
  Files           168      168              
  Lines          8756     8767      +11     
  Branches        878      878              
============================================
+ Hits           6893     6905      +12     
+ Misses         1463     1462       -1     
  Partials        400      400              
Flag Coverage Δ
ml-commons 78.76% <67.08%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../opensearch/ml/engine/encryptor/EncryptorImpl.java 91.04% <100.00%> (ø)
...tion/connector/DeleteConnectorTransportAction.java 94.91% <100.00%> (+0.08%) ⬆️
...tion/connector/SearchConnectorTransportAction.java 100.00% <100.00%> (ø)
...n/model_group/SearchModelGroupTransportAction.java 100.00% <100.00%> (ø)
...va/org/opensearch/ml/indices/MLIndicesHandler.java 59.34% <100.00%> (ø)
...a/org/opensearch/ml/model/MLModelGroupManager.java 83.76% <100.00%> (+0.13%) ⬆️
...rithms/metrics_correlation/MetricsCorrelation.java 0.00% <0.00%> (ø)
...h/ml/action/deploy/TransportDeployModelAction.java 82.85% <66.66%> (+0.12%) ⬆️
...tion/prediction/TransportPredictionTaskAction.java 78.72% <72.72%> (+0.94%) ⬆️
...n/java/org/opensearch/ml/model/MLModelManager.java 63.36% <52.63%> (+0.39%) ⬆️

@rbhavna rbhavna merged commit 47a45ae into opensearch-project:2.9 Oct 3, 2023
9 checks passed
ylwu-amzn added a commit to ylwu-amzn/ml-commons that referenced this pull request Oct 3, 2023
ylwu-amzn added a commit that referenced this pull request Oct 3, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2023
Signed-off-by: Yaliang Wu <ylwu@amazon.com>
(cherry picked from commit 9359487)
ylwu-amzn added a commit that referenced this pull request Oct 4, 2023
…#1435)

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
(cherry picked from commit 9359487)

Co-authored-by: Yaliang Wu <ylwu@amazon.com>
TrungBui59 pushed a commit to TrungBui59/ml-commons that referenced this pull request Nov 21, 2023
…ject#1418) (opensearch-project#1422) (opensearch-project#1435)

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
(cherry picked from commit 9359487)

Co-authored-by: Yaliang Wu <ylwu@amazon.com>
Signed-off-by: TrungBui59 <bui23@purdue.edu>
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.

None yet

3 participants