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

enable auto redeploy for hidden model #2102

Merged
merged 3 commits into from
Feb 19, 2024

Conversation

rbhavna
Copy link
Collaborator

@rbhavna rbhavna commented Feb 13, 2024

Description

enable auto redeploy for hidden model

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: Bhavana Ramaram <rbhavna@amazon.com>
}

public MLDeployModelRequest(String modelId, boolean async) {
this(modelId, null, async, true);
this(modelId, null, async, true, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] may be add a comment why here isUserInitiatedDeployRequest will always be true?

}

public MLDeployModelRequest(StreamInput in) throws IOException {
super(in);
this.modelId = in.readString();
this.modelNodeIds = in.readOptionalStringArray();
this.async = in.readBoolean();
this.isUserInitiatedDeployRequest = in.readOptionalBoolean();
Copy link
Collaborator

Choose a reason for hiding this comment

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

why optionalboolean? what'll happen if the value isn't present?

Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (67e904e) 81.83% compared to head (9b65523) 81.83%.
Report is 10 commits behind head on 2.x.

Files Patch % Lines
...h/ml/action/deploy/TransportDeployModelAction.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #2102      +/-   ##
============================================
- Coverage     81.83%   81.83%   -0.01%     
+ Complexity     5621     5620       -1     
============================================
  Files           543      543              
  Lines         22819    22825       +6     
  Branches       2339     2340       +1     
============================================
+ Hits          18675    18679       +4     
- Misses         3210     3213       +3     
+ Partials        934      933       -1     
Flag Coverage Δ
ml-commons 81.83% <90.90%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@arjunkumargiri arjunkumargiri left a comment

Choose a reason for hiding this comment

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

Can we follow similar logic for non-hidden models to bypass access check in case the request is system initiated? : https://github.com/opensearch-project/ml-commons/pull/2102/files#diff-c341f5a67c1d221e5593dd55fb689e9d0c9a60d33e0fa26090803cfa90818fa7R162

@@ -286,6 +286,7 @@ public void testDoExecute_no_permission_hidden_model() {
MLModel mlModel = mock(MLModel.class);
when(mlModel.getAlgorithm()).thenReturn(FunctionName.ANOMALY_LOCALIZATION);
when(mlModel.getIsHidden()).thenReturn(true);
when(mlDeployModelRequest.isUserInitiatedDeployRequest()).thenReturn(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add unit test to cover isUserInitiatedDeployRequest set to false.

@rbhavna
Copy link
Collaborator Author

rbhavna commented Feb 14, 2024

Can we follow similar logic for non-hidden models to bypass access check in case the request is system initiated? : https://github.com/opensearch-project/ml-commons/pull/2102/files#diff-c341f5a67c1d221e5593dd55fb689e9d0c9a60d33e0fa26090803cfa90818fa7R162

This is already handled in the validateModelGroupAccess method. But it checks for user being null and skips access check which handles the auto redeploy scenario

@@ -857,7 +857,7 @@ private void updateModelRegisterStateAsDone(
void deployModelAfterRegistering(MLRegisterModelInput registerModelInput, String modelId) {
String[] modelNodeIds = registerModelInput.getModelNodeIds();
log.debug("start deploying model after registering, modelId: {} on nodes: {}", modelId, Arrays.toString(modelNodeIds));
MLDeployModelRequest request = new MLDeployModelRequest(modelId, modelNodeIds, false, true);
MLDeployModelRequest request = new MLDeployModelRequest(modelId, modelNodeIds, false, true, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if user define a flow template with deploy hidden model action in it ? Can user deploy any hidden model?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't hidden model management (register, deploy, undeploy, delete) is out of scope for AI-Flow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With a flow template, we will still consider it as user initiated right. So we will still check for access. Only if it is system initiated, we will bypass the access checks

Copy link
Collaborator

@ylwu-amzn ylwu-amzn Feb 14, 2024

Choose a reason for hiding this comment

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

Isn't hidden model management (register, deploy, undeploy, delete) is out of scope for AI-Flow?

Yes for normal process, but that's not a hard control. User can copy the hidden model id and define a flow template to deploy it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can user see the hidden model id? I thought only superAdmin can see it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can user see the hidden model id? I thought only superAdmin can see it.

model id isn't hidden to users. But model content is hidden to users. During prediction, model id is being used. As user can make the prediction request, they can know the model id eventually.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes for normal process, but that's not a hard control. User can copy the hidden model id and define a flow template to deploy it.

We opened this deploy request to clients and then user initiated request flag is being set to true from code. So every request sent from ai-flow or any other clients should be treated as user initiated request too.

@arjunkumargiri
Copy link
Contributor

Can we follow similar logic for non-hidden models to bypass access check in case the request is system initiated? : https://github.com/opensearch-project/ml-commons/pull/2102/files#diff-c341f5a67c1d221e5593dd55fb689e9d0c9a60d33e0fa26090803cfa90818fa7R162

This is already handled in the validateModelGroupAccess method. But it checks for user being null and skips access check which handles the auto redeploy scenario

Null user checks is a workaround, can we explicitly check if deploy request is not user initiated so that same behavior is maintained for system initiated deployments?

Signed-off-by: Bhavana Ramaram <rbhavna@amazon.com>
@@ -38,24 +38,32 @@ public class MLDeployModelRequest extends MLTaskRequest {
private String modelId;
private String[] modelNodeIds;
boolean async;
// This is to identify if the get request is initiated by user or not. During auto redeploy also, we perform deploy operation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] this is a deploy request not a get request.

@dhrubo-os
Copy link
Collaborator

Can we follow similar logic for non-hidden models to bypass access check in case the request is system initiated? : https://github.com/opensearch-project/ml-commons/pull/2102/files#diff-c341f5a67c1d221e5593dd55fb689e9d0c9a60d33e0fa26090803cfa90818fa7R162

This is already handled in the validateModelGroupAccess method. But it checks for user being null and skips access check which handles the auto redeploy scenario

Null user checks is a workaround, can we explicitly check if deploy request is not user initiated so that same behavior is maintained for system initiated deployments?

@rbhavna are we planning to address this?

@rbhavna
Copy link
Collaborator Author

rbhavna commented Feb 19, 2024

Can we follow similar logic for non-hidden models to bypass access check in case the request is system initiated? : https://github.com/opensearch-project/ml-commons/pull/2102/files#diff-c341f5a67c1d221e5593dd55fb689e9d0c9a60d33e0fa26090803cfa90818fa7R162

This is already handled in the validateModelGroupAccess method. But it checks for user being null and skips access check which handles the auto redeploy scenario

Null user checks is a workaround, can we explicitly check if deploy request is not user initiated so that same behavior is maintained for system initiated deployments?

@rbhavna are we planning to address this?

Yes this has been addressed already https://github.com/opensearch-project/ml-commons/pull/2102/files#diff-c341f5a67c1d221e5593dd55fb689e9d0c9a60d33e0fa26090803cfa90818fa7R147

Signed-off-by: Bhavana Ramaram <rbhavna@amazon.com>
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:09 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:09 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:09 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:09 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:09 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:09 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:37 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:37 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env February 19, 2024 22:37 — with GitHub Actions Inactive
@rbhavna rbhavna merged commit 9567ca5 into opensearch-project:2.x Feb 19, 2024
15 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 19, 2024
* enable auto redeploy for hidden model

Signed-off-by: Bhavana Ramaram <rbhavna@amazon.com>
(cherry picked from commit 9567ca5)
ylwu-amzn pushed a commit that referenced this pull request Feb 20, 2024
* enable auto redeploy for hidden model

Signed-off-by: Bhavana Ramaram <rbhavna@amazon.com>
(cherry picked from commit 9567ca5)

Co-authored-by: Bhavana Ramaram <rbhavna@amazon.com>
austintlee pushed a commit to austintlee/ml-commons that referenced this pull request Mar 19, 2024
…search-project#2136)

* enable auto redeploy for hidden model

Signed-off-by: Bhavana Ramaram <rbhavna@amazon.com>
(cherry picked from commit 9567ca5)

Co-authored-by: Bhavana Ramaram <rbhavna@amazon.com>
@Zhangxunmt
Copy link
Collaborator

Why this PR is not backported to main?

@rbhavna
Copy link
Collaborator Author

rbhavna commented Mar 19, 2024

Why this PR is not backported to main?

This was merged in this PR @Zhangxunmt #2136

Zhangxunmt pushed a commit to Zhangxunmt/ml-commons that referenced this pull request Mar 21, 2024
…search-project#2136)

* enable auto redeploy for hidden model

Signed-off-by: Bhavana Ramaram <rbhavna@amazon.com>
(cherry picked from commit 9567ca5)

Co-authored-by: Bhavana Ramaram <rbhavna@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants