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

Feature/QueryGroup Add Create API in plugin #14459

Closed

Conversation

ruai0511
Copy link
Contributor

Description

This change introduces the Create QueryGroup API which we will use to enforce node level resiliency as part of this RFC: #12342.

The Create QueryGroup API schema is:

curl -XPUT "localhost:9200/_query_group/" -H 'Content-Type: application/json' -d ' 
{
     "name": "analytics",
     "jvm":0.4,
     "mode": "monitor"
}'

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • 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.

kaushalmahi12 and others added 17 commits April 11, 2024 21:15
Signed-off-by: Kaushal Kumar <[email protected]>
Signed-off-by: Kaushal Kumar <[email protected]>
Signed-off-by: Ruirui Zhang <[email protected]>
Signed-off-by: Ruirui Zhang <[email protected]>
Signed-off-by: Ruirui Zhang <[email protected]>
Signed-off-by: Ruirui Zhang <[email protected]>
Signed-off-by: Ruirui Zhang <[email protected]>
@ruai0511 ruai0511 force-pushed the QueryGroup-CRUD-create branch from a2bd381 to cb836d7 Compare June 19, 2024 19:13
Copy link
Contributor

❌ Gradle check result for a2bd381: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 5b53934: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

✅ Gradle check result for cb836d7: SUCCESS

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 55.65032% with 208 lines in your changes missing coverage. Please review.

Project coverage is 71.63%. Comparing base (b15cb0c) to head (cb836d7).
Report is 454 commits behind head on main.

Files Patch % Lines
...opensearch/plugin/wlm/CreateQueryGroupRequest.java 57.65% 42 Missing and 5 partials ⚠️
...ugin/wlm/service/QueryGroupPersistenceService.java 51.28% 36 Missing and 2 partials ⚠️
.../search/query_group/QueryGroupServiceSettings.java 25.58% 31 Missing and 1 partial ⚠️
...pensearch/cluster/metadata/QueryGroupMetadata.java 42.22% 26 Missing ⚠️
...ch/plugin/wlm/rest/RestCreateQueryGroupAction.java 0.00% 15 Missing ⚠️
...va/org/opensearch/cluster/metadata/QueryGroup.java 86.84% 6 Missing and 9 partials ⚠️
...ch/plugin/wlm/TransportCreateQueryGroupAction.java 0.00% 12 Missing ⚠️
...pensearch/plugin/wlm/CreateQueryGroupResponse.java 65.00% 7 Missing ⚠️
...java/org/opensearch/cluster/metadata/Metadata.java 73.68% 5 Missing ⚠️
...pensearch/plugin/wlm/WorkloadManagementPlugin.java 0.00% 4 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14459      +/-   ##
============================================
+ Coverage     71.42%   71.63%   +0.21%     
- Complexity    59978    62190    +2212     
============================================
  Files          4985     5129     +144     
  Lines        282275   292298   +10023     
  Branches      40946    42234    +1288     
============================================
+ Hits         201603   209385    +7782     
- Misses        63999    65635    +1636     
- Partials      16673    17278     +605     

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

@andrross
Copy link
Member

A couple high level comments:

@ruai0511
Copy link
Contributor Author

A couple high level comments:

Thanks for the info! I'll look into it

@kaushalmahi12
Copy link
Contributor

Thanks @andrross for going through the PR and provide useful insights. I have updated the RFC for the reasoning behind moving this into a plugin. We had also discussed this with @msfroh.

Comment on lines +27 to +28
- [QueryGroup] Add QueryGroup CRUD APIs ([#13315](https://github.com/opensearch-project/OpenSearch/pull/13315))
- [QueryGroup] Add QueryGroup Create API ([#14459](https://github.com/opensearch-project/OpenSearch/pull/14459))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Merge issue?

* compatible open source license.
*/

package org.opensearch.plugin.wlm;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should package be plugin.wlm.action? That would be consistent with the structure in core, I guess.

/**
* Name for CreateQueryGroupAction
*/
public static final String NAME = "cluster:admin/opensearch/query_group/wlm/_create";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have wlm prior to query_group in the action path?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is the right way since wlm is the umbrella under which these query groups come.

Comment on lines +28 to +29
private final QueryGroup queryGroup;
private RestStatus restStatus;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any other class example that follows this data object, restStatus response object model?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is NotSerializableExceptionWrapper. But I also see other classes that don't store reststatus and only store data.

/**
* Name for CreateQueryGroupAction
*/
public static final String NAME = "cluster:admin/opensearch/query_group/wlm/_create";
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is the right way since wlm is the umbrella under which these query groups come.

Comment on lines +95 to +97
for (String resourceName : resourceLimitMapOne.keySet()) {
assertTrue(resourceLimitMapTwo.containsKey(resourceName));
assertEquals(resourceLimitMapOne.get(resourceName), resourceLimitMapTwo.get(resourceName));
Copy link
Contributor

Choose a reason for hiding this comment

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

We can replace this with

Suggested change
for (String resourceName : resourceLimitMapOne.keySet()) {
assertTrue(resourceLimitMapTwo.containsKey(resourceName));
assertEquals(resourceLimitMapOne.get(resourceName), resourceLimitMapTwo.get(resourceName));
assertTrue(resourceLimitMapOne.keySet().containsAll(resourceLimitMapTwo.keySet()));
assertTrue(resourceLimitMapOne.values().containsAll(resourceLimitMapTwo.values()));

Comment on lines +103 to +113
for (QueryGroup groupOne : listOne) {
String groupOneName = groupOne.getName();
List<QueryGroup> groupTwoList = listTwo.stream().filter(sb -> sb.getName().equals(groupOneName)).collect(Collectors.toList());
assertEquals(1, groupTwoList.size());
QueryGroup groupTwo = groupTwoList.get(0);
assertEquals(groupOne.getName(), groupTwo.getName());
assertEquals(groupOne.get_id(), groupTwo.get_id());
compareResourceLimits(groupOne.getResourceLimits(), groupTwo.getResourceLimits());
assertEquals(groupOne.getMode(), groupTwo.getMode());
assertEquals(groupOne.getUpdatedAtInMillis(), groupTwo.getUpdatedAtInMillis());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How about sorting these two lists and then doing the index wise comparison I think that would be more efficient ?
If the query group already implements equalsTo method then we should leverage that.

@ruai0511 ruai0511 closed this Jul 9, 2024
@ruai0511
Copy link
Contributor Author

ruai0511 commented Jul 9, 2024

Move this to #14680 and close this PR

@ruai0511 ruai0511 mentioned this pull request Jul 15, 2024
8 tasks
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