-
Notifications
You must be signed in to change notification settings - Fork 146
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
applying multi-tenancy in search [model, model group, agent, connector] #3433
applying multi-tenancy in search [model, model group, agent, connector] #3433
Conversation
93b04e5
to
0b4eded
Compare
0b4eded
to
57f9afa
Compare
57f9afa
to
90745b2
Compare
90745b2
to
7f32eb9
Compare
7f32eb9
to
22620bc
Compare
22620bc
to
88dc346
Compare
Signed-off-by: Dhrubo Saha <[email protected]>
88dc346
to
9f653e8
Compare
import lombok.Getter; | ||
|
||
@Getter | ||
public class MLSearchActionRequest extends SearchRequest { |
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.
Add java documentation
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.
added
@@ -96,4 +129,26 @@ private void search(SearchRequest request, ActionListener<SearchResponse> action | |||
actionListener.onFailure(e); | |||
} | |||
} | |||
|
|||
@VisibleForTesting | |||
public static void wrapListenerToHandleConnectorIndexNotFound(Exception e, ActionListener<SearchResponse> listener) { |
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.
This method is currently not being used.
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.
This method is being used in unit tests. And after sdkclient implementation we will use it here if we need too.
|
||
// For multi-tenancy | ||
if (tenantId != null) { | ||
shouldQuery.should(QueryBuilders.termQuery(TENANT_ID_FIELD, tenantId)); | ||
} |
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.
Duplicate
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.
thanks, removed.
queryBuilder.must(request.source().query()); | ||
} | ||
// Add tenancy filter | ||
queryBuilder.filter(QueryBuilders.termQuery(TENANT_ID_FIELD, tenantId)); // Replace 'tenant_id_field' with actual field name |
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.
Is the comment valid?
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.
nope, removed.
Signed-off-by: Dhrubo Saha <[email protected]>
@Getter | ||
public class MLSearchActionRequest extends SearchRequest { | ||
SearchRequest searchRequest; | ||
String tenantId; |
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.
A new MLSearchActionRequest class was added to wrap the original SearchRequest and include a tenantId field.So I want to understand does it impact other functionality using SearchRequest?
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.
Can you please give me an example which functionality are you referring to?
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 think the order matters, when did the SearchRequest converts to MLSearchActionRequest? I am worry about the tools and search pipelines that are using the search requests. if the transform is after them, it should be fine, but if that's before tools and search pipelines, does it impact them?
for example
ml-commons/ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/SearchIndexTool.java
Line 84 in 06a6021
private SearchRequest getSearchRequest(String index, String query) throws IOException { |
Line 51 in 06a6021
public SearchRequest processRequest(SearchRequest request) throws Exception { |
return new MLSearchActionRequest(input); | ||
} | ||
} catch (IOException e) { | ||
throw new UncheckedIOException("failed to parse ActionRequest into MLSearchActionRequest", e); |
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.
In this exception handling, I think IllegalArgumentException is more proper in this case
The method is expecting an ActionRequest that can be converted to MLSearchActionRequest.
If the conversion fails, it's likely because the input ActionRequest is not of the expected type or format.
This is more of a logical/argument error than an I/O error.
I think if using IllegalArgumentException, it provides clearer feedback to the caller about what went wrong.
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.
This is literally the same method we use for all other request classes. Example
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-3433-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1422c7c6940143db4b92fba6fbb08a7acd10641b
# Push it to GitHub
git push --set-upstream origin backport/backport-3433-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
…r] (opensearch-project#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]>
…r] (opensearch-project#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]>
…r] (opensearch-project#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]>
…r] (opensearch-project#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]>
…agent, connector] (#3433) (#3443) * applying multi-tenancy in search [model, model group, agent, connector] (#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> * changing MLSearchActionRequest to an instance subclass of SearchActionRequest Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]>
…agent, connector] (#3433) (#3443) * applying multi-tenancy in search [model, model group, agent, connector] (#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> * changing MLSearchActionRequest to an instance subclass of SearchActionRequest Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit 34a7fb6)
…agent, connector] (#3433) (#3443) (#3469) * applying multi-tenancy in search [model, model group, agent, connector] (#3433) * applying multi-tenancy in search Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> * changing MLSearchActionRequest to an instance subclass of SearchActionRequest Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit 34a7fb6) Co-authored-by: Dhrubo Saha <[email protected]>
Description
[Describe what this change achieves]
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.