-
Notifications
You must be signed in to change notification settings - Fork 143
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
multi-tenancy + sdk client related changes in agents #3432
base: main
Are you sure you want to change the base?
Conversation
6b2ef3d
to
68ecd9a
Compare
68ecd9a
to
b3bd8b4
Compare
6eb19a3
to
3d9f58d
Compare
3d9f58d
to
eade048
Compare
eade048
to
0feb3b4
Compare
Signed-off-by: Dhrubo Saha <[email protected]>
0feb3b4
to
be09e92
Compare
@Override | ||
public void onMultiTenancyEnabledChanged(boolean isEnabled) { | ||
this.isMultiTenancyEnabled = isEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember this setting is static as
ml-commons/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java
Line 305 in 570edaf
public static final Setting<Boolean> ML_COMMONS_MULTI_TENANCY_ENABLED = Setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I developed this piece of code when we are thinking to change tenancy dynamically. But for now, we are keeping it as a static settings. But still piece of code applied, it doesn't harm. If we in the long run want to turn it to dynamic settings we won't need to do anything from our end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure that as a static setting it will never trigger this method at all. And you have to actually register listeners to get these notifications and I don't see that done. So it's half implemented. I agree it's harmless here but I'd rather see none or all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That registration happened in this PR: https://github.com/opensearch-project/ml-commons/pull/3307/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but you need to add a settings update consumer in the class where you want it to update. See https://github.com/search?q=repo%3Aopensearch-project%2Fml-commons%20addsettingsupdateconsumer&type=code
But I never see us register multitenancy (we did at one time on the feature branch but I think I removed it):
ml-commons/plugin/src/main/java/org/opensearch/ml/settings/MLFeatureEnabledSetting.java
Lines 46 to 73 in 570edaf
public MLFeatureEnabledSetting(ClusterService clusterService, Settings settings) { | |
isRemoteInferenceEnabled = ML_COMMONS_REMOTE_INFERENCE_ENABLED.get(settings); | |
isAgentFrameworkEnabled = ML_COMMONS_AGENT_FRAMEWORK_ENABLED.get(settings); | |
isLocalModelEnabled = ML_COMMONS_LOCAL_MODEL_ENABLED.get(settings); | |
isConnectorPrivateIpEnabled = new AtomicBoolean(ML_COMMONS_CONNECTOR_PRIVATE_IP_ENABLED.get(settings)); | |
isControllerEnabled = ML_COMMONS_CONTROLLER_ENABLED.get(settings); | |
isBatchIngestionEnabled = ML_COMMONS_OFFLINE_BATCH_INGESTION_ENABLED.get(settings); | |
isBatchInferenceEnabled = ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED.get(settings); | |
isMultiTenancyEnabled = ML_COMMONS_MULTI_TENANCY_ENABLED.get(settings); | |
clusterService | |
.getClusterSettings() | |
.addSettingsUpdateConsumer(ML_COMMONS_REMOTE_INFERENCE_ENABLED, it -> isRemoteInferenceEnabled = it); | |
clusterService | |
.getClusterSettings() | |
.addSettingsUpdateConsumer(ML_COMMONS_AGENT_FRAMEWORK_ENABLED, it -> isAgentFrameworkEnabled = it); | |
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_LOCAL_MODEL_ENABLED, it -> isLocalModelEnabled = it); | |
clusterService | |
.getClusterSettings() | |
.addSettingsUpdateConsumer(ML_COMMONS_CONNECTOR_PRIVATE_IP_ENABLED, it -> isConnectorPrivateIpEnabled.set(it)); | |
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_CONTROLLER_ENABLED, it -> isControllerEnabled = it); | |
clusterService | |
.getClusterSettings() | |
.addSettingsUpdateConsumer(ML_COMMONS_OFFLINE_BATCH_INGESTION_ENABLED, it -> isBatchIngestionEnabled = it); | |
clusterService | |
.getClusterSettings() | |
.addSettingsUpdateConsumer(ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED, it -> isBatchInferenceEnabled = it); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we just need to add it back here, that's all. So for now I'll keep the code as it is.
I have a high level question. It turns out we are to add a tenant id in MLToolSpec that means for every tool we will check the permission according to tenant id? From my point of view, we don't have any tools related APIs like create/delete, as we don't think of a tool as a resource. On the contrary, we consider the agent to be the resource for that we have create/delete APIs. So I am wondering if it is enough that we only have resource control on agents per tenant id. |
That a very good question. I agree with that. But the problem is, tool can make prediction to the model. But that model needs to be tenant specific. So which is why we are forwarding this tenant id everywhere. This way when tool wants to perform any operation we can check if this tool has enough permission to perform the operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A lot more complicated than I thought!
@Override | ||
public void onMultiTenancyEnabledChanged(boolean isEnabled) { | ||
this.isMultiTenancyEnabled = isEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure that as a static setting it will never trigger this method at all. And you have to actually register listeners to get these notifications and I don't see that done. So it's half implemented. I agree it's harmless here but I'd rather see none or all.
Description
[multi-tenancy + sdk client related changes in agents]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--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.