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 more places where thread context not restored #1421

Merged
merged 3 commits into from
Oct 3, 2023

Conversation

ylwu-amzn
Copy link
Collaborator

Description

Continue of #1418

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 <[email protected]>
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:10 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:10 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:10 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:10 — with GitHub Actions Inactive
modelAccessControlHelper.validateModelGroupAccess(user, mlModel.getModelGroupId(), client, listener);
}, e -> {
log.error("Failed to find Model", e);
listener.onFailure(e);
}));
}), () -> context.restore()));
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the context restored anyway after this statement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, but the action listener is running inside it

@@ -80,6 +80,7 @@ public void search(SearchRequest request, ActionListener<SearchResponse> actionL
User user = RestActionUtils.getUserContext(client);
ActionListener<SearchResponse> listener = wrapRestActionListener(actionListener, "Fail to search model version");
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
ActionListener<SearchResponse> wrappedListener = ActionListener.runBefore(listener, () -> context.restore());
Copy link
Member

Choose a reason for hiding this comment

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

I assume we can't provide this listener as generic from utils because context doesn't exist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

dhrubo-os
dhrubo-os previously approved these changes Oct 3, 2023
@@ -9,6 +9,8 @@
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
import static org.opensearch.ml.utils.RestActionUtils.PARAMETER_MODEL_GROUP_ID;

import javax.swing.*;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Self review and find this , should remove this line

Signed-off-by: Yaliang Wu <[email protected]>
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:46 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:46 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:46 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env October 3, 2023 17:46 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #1421 (f75eeda) into 2.9 (47a45ae) will decrease coverage by 0.09%.
The diff coverage is 82.81%.

@@             Coverage Diff              @@
##                2.9    #1421      +/-   ##
============================================
- Coverage     78.81%   78.73%   -0.09%     
- Complexity     2156     2160       +4     
============================================
  Files           168      168              
  Lines          8767     8775       +8     
  Branches        878      878              
============================================
- Hits           6910     6909       -1     
- Misses         1456     1465       +9     
  Partials        401      401              
Flag Coverage Δ
ml-commons 78.73% <82.81%> (-0.09%) ⬇️

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

Files Coverage Δ
...search/ml/action/tasks/GetTaskTransportAction.java 62.50% <100.00%> (ø)
...rch/ml/action/tasks/SearchTaskTransportAction.java 72.72% <100.00%> (ø)
...action/undeploy/TransportUndeployModelsAction.java 94.00% <100.00%> (ø)
.../opensearch/ml/action/handler/MLSearchHandler.java 87.36% <83.33%> (+0.13%) ⬆️
...n/model_group/DeleteModelGroupTransportAction.java 92.68% <85.71%> (+0.18%) ⬆️
...h/ml/action/models/DeleteModelTransportAction.java 83.89% <90.00%> (+0.13%) ⬆️
...arch/ml/action/models/GetModelTransportAction.java 82.69% <90.00%> (+0.33%) ⬆️
...rch/ml/action/tasks/DeleteTaskTransportAction.java 89.18% <83.33%> (+0.30%) ⬆️
...n/model_group/TransportUpdateModelGroupAction.java 78.03% <66.66%> (+0.33%) ⬆️
...h/ml/action/upload_chunk/MLModelChunkUploader.java 87.70% <72.72%> (+0.10%) ⬆️

... and 3 files with indirect coverage changes

@ylwu-amzn ylwu-amzn merged commit 1b33d6d 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
…#1421)

* fix more places where thread context not restored

Signed-off-by: Yaliang Wu <[email protected]>

* fix failed ut

Signed-off-by: Yaliang Wu <[email protected]>

* remove unused import

Signed-off-by: Yaliang Wu <[email protected]>

---------

Signed-off-by: Yaliang Wu <[email protected]>
ylwu-amzn added a commit that referenced this pull request Oct 3, 2023
* fix more places where thread context not restored



* fix failed ut



* remove unused import



---------

Signed-off-by: Yaliang Wu <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2023
* fix more places where thread context not restored

* fix failed ut

* remove unused import

---------

Signed-off-by: Yaliang Wu <[email protected]>
(cherry picked from commit d8c1162)
dhrubo-os pushed a commit that referenced this pull request Oct 5, 2023
)

* fix more places where thread context not restored

* fix failed ut

* remove unused import

---------

Signed-off-by: Yaliang Wu <[email protected]>
(cherry picked from commit d8c1162)

Co-authored-by: Yaliang Wu <[email protected]>
TrungBui59 pushed a commit to TrungBui59/ml-commons that referenced this pull request Nov 21, 2023
…#1421) (opensearch-project#1423) (opensearch-project#1436)

* fix more places where thread context not restored

* fix failed ut

* remove unused import

---------

Signed-off-by: Yaliang Wu <[email protected]>
(cherry picked from commit d8c1162)

Co-authored-by: Yaliang Wu <[email protected]>
Signed-off-by: TrungBui59 <[email protected]>
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.

4 participants