-
Notifications
You must be signed in to change notification settings - Fork 670
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
SOLR-16390: v2 Cluster Property APIs. #2788
SOLR-16390: v2 Cluster Property APIs. #2788
Conversation
List ClusterProps sample response:
Fetch Single ClusterProp sample responses:
Wasn't sure how to model the response. Different APIs use different error for "does not exist" responses: |
Known TODOs:
|
Still going through the individual files on this PR, but wanted to respond to some of the high-level comments first:
I'm personally a fan of 404 in this case as it seems a little more actionable for users than the more generic '400', so that'd be my preference. But I don't have any strong feelings on that point, and would be open to something else if you do have preferences? When we decide, we should document the decision in (I suspect the 405 returned by
I prefer grouping related APIs into a single file, at least on the 'api' side. IMO it cuts down on boilerplate, and makes reviewing and browsing easier by keeping a bunch of related definitions together. But again, it's a very slight preference on my end if you happen to prefer the alternative.
Hmm - I think you should be able to nuke
Or does that break something or other that I've forgotten about? |
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 for the PR @cugarte!
I left a few inline comments - mostly small fixes like missing @PermissionName
annotations. (I've also replied to a few of your questions in a preceding comment, in case you miss it.)
But overall this looks great. Should be pretty close to being merge-ready! Lmk if you have any questions about the feedback!
solr/api/src/java/org/apache/solr/client/api/endpoint/SetClusterPropertyApi.java
Outdated
Show resolved
Hide resolved
@Operation( | ||
summary = "Set nested cluster properties in this Solr cluster", | ||
tags = {"cluster-properties"}) | ||
SolrJerseyResponse createOrUpdateNestedClusterProperty( |
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.
[Q] It's interesting that this API is both the only way to set "nested"/complex cluster properties, and the only way to set multiple properties simultaneously.
I guess that's fine, since it mirrors what's supported in v1? I don't really have a question or suggestion here, mostly just making a note of it...
@@ -907,6 +912,11 @@ private void loadInternal() { | |||
ClusterAPI clusterAPI = new ClusterAPI(collectionsHandler, configSetsHandler); | |||
registerV2ApiIfEnabled(clusterAPI); | |||
registerV2ApiIfEnabled(clusterAPI.commands); | |||
registerV2ApiIfEnabled(ListClusterProperties.class); |
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.
[0] Not a huge deal either way, but it's prob a bit cleaner to register these APIs from within CollectionsHandler
, where the v1 logic (such as it is) lives. (See CollectionsHandler.getJerseyResources
)
CoreContainer is already pretty bloated so the more API-registration we can defer to individual request-handler's, the better IMO
} catch (Exception e) { | ||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in API", e); | ||
} | ||
SetNestedClusterPropertyRequestBody setNestedClusterPropertyRequestBody = |
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.
[-1] SetNestedClusterPropertyApi/SetNestedClusterProperty provide an improved v2 API for this functionality, so IMO we should delete this method outright, rather than keeping the older v2 API around.
(v2 APIs are "experimental", so there's no backcompat concerns with removing/changing them as necessary)
super(coreContainer.getZkController().getZkClient()); | ||
} | ||
|
||
@Override |
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.
[-1] We want all APIs to have an @PermissionName
annotation, so that they can be mapped to the predefined permissions that Solr's RuleBasedAuth plugin knows about. In terms of the what permission - COLL_READ
seems like the best fit at a glance to me. Wdyt?
(Same comment applies to GetClusterProperty, but I think all the others are good!)
try { | ||
clusterProperties.setClusterProperties(requestBody.properties); | ||
} catch (Exception e) { | ||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in API", 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.
[0] Not the most helpful error message, but I can see it came straight from the pre-existing "set-obj-property" API.
Commenting here as a reminder to myself to fix this and a few other places in a subsequent PR.
} | ||
|
||
@Test | ||
public void testClusterPropertyOpsAllGood() throws Exception { |
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.
[+1] Great tests - afaict we have very little coverage around cluster-props so this is a huge improvement!
[-0] These tests seem like a good candidate for using the SolrJ classes generated by your API definitions (i.e. o.a.s.client.solrj.request.ClusterPropertiesApi
).
Doing so feels a bit circular (i.e. any bugs in the JAX-RS annotations would get propagated to the generated code and might not be caught)...but it'd help the tests to scan a lot nicer IMO, and it'd get us coverage for the SolrJ classes to boot, so it sees like a worthwhile tradeoff IMO. Wdyt?
…erPropertyApi.java Co-authored-by: Jason Gerlowski <gerlowskija@apache.org>
Thank you for the detailed feedback, @gerlowskija! I've updated the code to reflect most of the changes you suggested. Specifically,
A couple of code suggestions are outstanding:
I hadn't thought of this earlier, but think it's a good idea as it would let us test the SolrJ classes. I don't know enough about the code generation or how annotation bugs might lead to masking errors - perhaps it would be helpful to have a specific set of tests that checks an underlying API in multiple ways (using the SolrJ APIs and HttpClient calls or something similar?) but generally let test code just use the SolrJ APIs? In any event, I'm running into a couple of problems here that I think are related to code generation. Problem 1: I added one new unit test (
Problem 2: when I did this, the generated code below (in this.requestBody = new Map<String, Object>(); as Map is an abstract class. Replacing Question 1: while I also prefer having related calls be in the same class, this has resulted in two similarly named classes that could be confusing: TODOs:
|
Just saw your changes to I gather the correct changes to |
sigh No it's not a template problem - I think you've uncovered a design implication I hadn't realized up until now. In short - SolrClients typically parse the response into a "NamedList" that is then immediately inspected to see whether there were any server errors that should result in a client-side exception. But for these generated v2 classes, the response-parsing happens much much later - nothing gets parsed until the caller has already received a SolrResponse instance and invokes a special It's fixable, but definitely beyond the scope of what we'd want to bring into this PR. I've created a separate JIRA ticket to discuss more: https://issues.apache.org/jira/browse/SOLR-17549 In the meantime - forget I said anything about having tests that use the generated SolrJ objects. I'd love to backfill those tests later once we've worked out some of the kinks in how the generated classes need to work, but that shouldn't block this PR. |
The discussion here has gotten a bit long, but to summarize my understanding: "Problem 1" and "Problem 2" are both resolved, the first by virtue of being punted to SOLR-17549 and the second by a minor 'api.mustache' template fix. I think that only leaves the two more minor "TODOs" Carlos mentioned above:
Lmk if that's right! |
Thanks @gerlowskija ! The punting of "Problem 1" does resolve all of the outstanding issues, and the commit I just pushed added the two missing bits of documentation that you noted. |
Alright, appreciate the latest round of docs, and with those latest changes this now LGTM. I'll leave a few days for other feedback to trickle in but will aim to merge towards the end of the week otherwise. Thanks Carlos! |
Alright, gearing up to merge this now. I've added a CHANGES.txt entry for this - ended up being pretty chunky since this PR both makes a few existing APIs easier to grok, as well as adding a few new ones entirely. Very cool! One final note - a few files (ClusterPropertyApis.java and ClusterProperty.java) were missing license headers that the ASF requires in every file, so I've added those in. Thanks again Carlos! |
This commit changes several v2 "clusterprop" APIs to be more in line with the REST-ful design we're targeting for Solr's v2 APIs. It also adds new v2 clusterprop APIs for listing-all and fetching- single clusterprops. --------- Co-authored-by: Jason Gerlowski <gerlowskija@apache.org>
Thanks, Jason! And apologies for the broken tests that you had to fix. |
Test Failing!
|
https://issues.apache.org/jira/browse/SOLR-16390
Description
v2 (JAX-RS) endpoints for Cluster Property operations.
Solution
This commit adds the following v2 JAX-RS Cluster Property APIs:
GET /api/cluster/properties
PUT /api/cluster/properties/propName {"value": "propVal"}
PUT /api/cluster/properties {...}
GET /api/cluster/properties/propName
DELETE /api/cluster/properties/propName
Tests
The existing Cluster Property tests cover the "Create/Update Single ClusterProp", "Create/Update Nested ClusterProp" and "Delete ClusterProp". I added unit tests for the new APIs (
ClusterPropsAPITest
).Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.