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

SOLR-15748 : Created v2 equivalent of v1 'CLUSTERSTATUS' command #1061

Merged
merged 9 commits into from Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions solr/CHANGES.txt
Expand Up @@ -46,6 +46,9 @@ Improvements
* SOLR-16392: A number of v2 "replica" endpoints have been updated to be more REST-ful, and hopefully, intuitive.
ADDREPLICAPROP is now `PUT /api/collections/$coll/shards/$shard/replicas/$rep/properties/$prop {"value": $val}`

* SOLR-15478: A v2 equivalent of CLUSTERSTATUS command is now available at `GET /api/cluster`. Collection listing,
previously at this path, can still be accessed at `GET /api/collections`. (Joshua Ouma via Jason Gerlowski)

Optimizations
---------------------
(No changes)
Expand Down
15 changes: 9 additions & 6 deletions solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
Expand Up @@ -25,7 +25,6 @@
import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDROLE;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.CLUSTERPROP;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETESTATUS;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.LIST;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.OVERSEERSTATUS;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.REMOVEROLE;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.REQUESTSTATUS;
Expand All @@ -52,6 +51,8 @@
import org.apache.solr.common.cloud.ClusterProperties;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.DefaultSolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ReflectMapWriter;
Expand Down Expand Up @@ -209,11 +210,6 @@ public void getOverseerStatus(SolrQueryRequest req, SolrQueryResponse rsp) throw
collectionsHandler.handleRequestBody(wrapParams(req, "action", OVERSEERSTATUS.lowerName), rsp);
}

@EndPoint(method = GET, path = "/cluster", permission = COLL_READ_PERM)
public void getCluster(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
collectionsHandler.handleRequestBody(wrapParams(req, "action", LIST.lowerName), rsp);
}

@EndPoint(method = DELETE, path = "/cluster/command-status/{id}", permission = COLL_EDIT_PERM)
public void deleteCommandStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
final Map<String, Object> v1Params = Maps.newHashMap();
Expand Down Expand Up @@ -261,6 +257,13 @@ public void getNodes(SolrQueryRequest req, SolrQueryResponse rsp) {
rsp.add("nodes", getCoreContainer().getZkController().getClusterState().getLiveNodes());
}

@EndPoint(method = GET, path = "/cluster", permission = COLL_READ_PERM)
Copy link
Contributor

Choose a reason for hiding this comment

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

The COLL_READ_PERM (collection-admin-read) permission here stems from when CLUSTERSTATUS was a collection-api command.

The content of clusterstatus is mostly collection data, i.e. a list of collections, their shards and replicas and their status. So I'm OK with keeping this permission although it is now located under/api/cluster. I'm thinking of the CloudSolrClient SolrJ client that will read cluster status in order to route index/search requests.

Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I'm still learning the code base and how Solr works, I'll have to look into how the CloudSolrClient works to better understand your point and put across my thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not expecting you to have an opinion on this detail. Solr's security framework is a bit involved :) But if a committer has an opinion I'm happy to hear it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you getting at the fact that COLL_READ_PERM/collection-admin-read is a bad name in the v2 world where /admin/collections no longer exists? Or are you suggesting that it might be nice to give "cluster status" a different permission group so that CSC's can be setup to require fewer permissions? Or something else altogether?

If the former, then I totally agree. I think it still makes sense to have a permission group like COLL_READ_PERM going forward, but the name would need to be rethought. Regardless of the underlying api paths or the permission name though, I think users will still find it valuable to group various admin-read functionality in a single permission-group.

In terms of having a "slimmer" predefined permission group for HttpClusterStateProvider-based CloudSolrClients to use, that seems like it might be useful. Though, to play devil's advocate, IMO HttpClusterStateProvider is sort of a minority use-case, and users that want to run a HCSP without giving it full COLL_READ_PERMs can already do so by defining "custom permissions". So I could go either way I guess 🤷

In either case - IMO making changes to our predefined permissions is definitely a bigger task that we'd want to be a separate JIRA for sure.

public void getClusterStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
final Map<String, Object> v1Params = Maps.newHashMap();
v1Params.put(CommonParams.ACTION, CollectionAction.CLUSTERSTATUS.toLower());
collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);
}

private CoreContainer getCoreContainer() {
return collectionsHandler.getCoreContainer();
}
Expand Down
Expand Up @@ -34,6 +34,7 @@
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiBag;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.CommandOperation;
import org.apache.solr.common.util.ContentStreamBase;
Expand Down Expand Up @@ -95,10 +96,10 @@ public void testClusterOverseerAllParams() throws Exception {
}

@Test
public void testListClusterAllParams() throws Exception {
public void testClusterStatusAllParams() throws Exception {
final SolrParams v1Params = captureConvertedV1Params("/cluster", "GET", null);

assertEquals(CollectionParams.CollectionAction.LIST.lowerName, v1Params.get(ACTION));
assertEquals(CollectionAction.CLUSTERSTATUS.lowerName, v1Params.get(ACTION));
}

@Test
Expand Down
Expand Up @@ -60,8 +60,11 @@ http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS
====
[.tab-label]*V2 API*

We do not currently have a V2 equivalent.
[source,bash]
----
curl -X GET http://localhost:8983/api/cluster

----
====
--

Expand Down