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

adding multi-tenancy to config api and master key related changes #3439

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

dhrubo-os
Copy link
Collaborator

Description

[adding multi-tenancy to config api and master key related changes]

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@dhrubo-os dhrubo-os force-pushed the multi_tenancy_config branch from 6b5ad0a to 9578ff1 Compare January 28, 2025 00:27
@dhrubo-os dhrubo-os changed the title adding multi-tenancy to config api and master key related changes [DRAFT] adding multi-tenancy to config api and master key related changes Jan 28, 2025
@dhrubo-os dhrubo-os force-pushed the multi_tenancy_config branch 2 times, most recently from f897de2 to 4f70041 Compare January 28, 2025 01:21
@dhrubo-os dhrubo-os temporarily deployed to ml-commons-cicd-env January 28, 2025 01:23 — with GitHub Actions Inactive
@dhrubo-os dhrubo-os marked this pull request as ready for review January 28, 2025 01:32
@dhrubo-os dhrubo-os changed the title [DRAFT] adding multi-tenancy to config api and master key related changes adding multi-tenancy to config api and master key related changes Jan 28, 2025
Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
@dhrubo-os dhrubo-os temporarily deployed to ml-commons-cicd-env January 28, 2025 03:37 — with GitHub Actions Inactive
@dhrubo-os dhrubo-os temporarily deployed to ml-commons-cicd-env January 28, 2025 04:35 — with GitHub Actions Inactive
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 69.67213% with 37 lines in your changes missing coverage. Please review.

Project coverage is 80.45%. Comparing base (f28bb74) to head (6e94702).
Report is 181 commits behind head on main.

Files with missing lines Patch % Lines
...ml/action/tasks/CancelBatchJobTransportAction.java 40.00% 6 Missing ⚠️
...va/org/opensearch/ml/common/utils/StringUtils.java 0.00% 5 Missing ⚠️
.../opensearch/ml/engine/encryptor/EncryptorImpl.java 85.71% 4 Missing and 1 partial ⚠️
...ction/deploy/TransportDeployModelOnNodeAction.java 0.00% 4 Missing ⚠️
...org/opensearch/ml/rest/RestMLPredictionAction.java 0.00% 4 Missing ⚠️
...va/org/opensearch/ml/task/MLPredictTaskRunner.java 69.23% 4 Missing ⚠️
...rch/ml/action/config/GetConfigTransportAction.java 57.14% 2 Missing and 1 partial ⚠️
...n/java/org/opensearch/ml/model/MLModelManager.java 0.00% 3 Missing ⚠️
.../opensearch/ml/common/connector/HttpConnector.java 66.66% 1 Missing ⚠️
...search/ml/action/tasks/GetTaskTransportAction.java 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3439      +/-   ##
============================================
- Coverage     81.31%   80.45%   -0.87%     
- Complexity     6094     6723     +629     
============================================
  Files           573      599      +26     
  Lines         25268    29186    +3918     
  Branches       2666     3232     +566     
============================================
+ Hits          20547    23481    +2934     
- Misses         3601     4304     +703     
- Partials       1120     1401     +281     
Flag Coverage Δ
ml-commons 80.45% <69.67%> (-0.87%) ⬇️

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.

Looks good. Please add missing unit test for lines missing code coverage.

}

@Override
protected void doExecute(Task task, ActionRequest request, ActionListener<MLConfigGetResponse> actionListener) {
MLConfigGetRequest mlConfigGetRequest = MLConfigGetRequest.fromActionRequest(request);
String configId = mlConfigGetRequest.getConfigId();
String tenantId = mlConfigGetRequest.getTenantId();
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently tenantId is not being used. Please add a comment that tenantId will be used as part of SDKClient migration.

@b4sjoo
Copy link
Collaborator

b4sjoo commented Jan 28, 2025

I do see a lot of place did not cover by UT according to codecov report. I know the release time line is quite tense but could you please mark them and add those later?

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

LGTM with a question

Comment on lines +192 to +193
case TENANT_ID_FIELD:
tenantId = parser.textOrNull();
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the tenant ID field added to the config? We use a hash of the key as part of the document ID and never actually compare vs. this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We had is here in the multi-tenancy branch, I will deep dive later (after merging all the code) if we can remove it from here.

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
@dhrubo-os dhrubo-os force-pushed the multi_tenancy_config branch from 518f7a8 to 6e94702 Compare January 28, 2025 18:03
@dhrubo-os dhrubo-os temporarily deployed to ml-commons-cicd-env January 28, 2025 19:10 — with GitHub Actions Inactive
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.

Code changes looks good. Seems build is failing due to flaky test. Please validate that build succeeds before merging.

@dhrubo-os dhrubo-os temporarily deployed to ml-commons-cicd-env January 28, 2025 19:46 — with GitHub Actions Inactive
@@ -48,50 +53,52 @@ public class EncryptorImpl implements Encryptor {
"The ML encryption master key has not been initialized yet. Please retry after waiting for 10 seconds.";
private ClusterService clusterService;
private Client client;
private volatile String masterKey;
private final Map<String, String> tenantMasterKeys;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get why we have different key for every tenant. Currently this key is shared on the cluster level and crosses users. It's only for the node internal use, doesn't matter with user information. If we did so, we would also need to have different key for every user.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tenant isn't an user here. So every tenant will have their own separate master key which will be used to encrypt/decrypt their connector credentials. If we have only one master key, that'll be a security concern for multi-tenancy.

@dhrubo-os dhrubo-os merged commit 9846e6e into opensearch-project:main Jan 28, 2025
9 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 28, 2025
)

* adding multi-tenancy to config api and master key related changes

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>

* adding more unit tests

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>

---------

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
(cherry picked from commit 9846e6e)
@dhrubo-os dhrubo-os temporarily deployed to ml-commons-cicd-env January 28, 2025 20:45 — with GitHub Actions Inactive
dhrubo-os added a commit that referenced this pull request Jan 29, 2025
) (#3444)

* adding multi-tenancy to config api and master key related changes

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>

* adding more unit tests

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>

---------

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
(cherry picked from commit 9846e6e)

Co-authored-by: Dhrubo Saha <dhrubo@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