Skip to content

feat(cluster): return get-cluster-status and list-configsets as records - #295

Closed
adityamparikh wants to merge 9 commits into
apache:mainfrom
adityamparikh:feat/cluster-records
Closed

adityamparikh wants to merge 9 commits into
apache:mainfrom
adityamparikh:feat/cluster-records

Conversation

@adityamparikh

Copy link
Copy Markdown
Contributor

Stacked on #270 (get-cluster-status, list-configsets), with current main merged in: review the last commit only.

Summary

get-cluster-status, solr://cluster/status and list-configsets return records instead of nested maps and a bare list.

ClusterStatus(collections, liveNodes "live_nodes", other)            # other: aliases, roles, properties…
  Collection(health, configName, shards, other)                      # other: router, replicationFactor, znodeVersion…
    Shard(state, health, range, replicas, other)
      Replica(core, nodeName "node_name", state, type, leader, other) # other: base_url, force_set_state…
ConfigSetList(configSets, other)                                     # names sorted, as before

The records type what the tool description tells the model to read and compute nothing: replica state, leader and shard/collection health are Solr's own values, so the derived healthy/issues fields #270 removed are not reintroduced. Every other property is kept in a @JsonAnySetter @JsonAnyGetter catch-all and written back at the same level, so the JSON keeps Solr's keys and a property a later Solr version adds is passed on.

One value changes type:

-"leader": "true"
+"leader": true

Evidence

  • ClusterServiceTest.getClusterStatus_coercesLeaderAndKeepsUntypedProperties: "leader":"true" becomes "leader":true; base_url, router and an unknown top-level section reach the JSON unchanged; no other key.
  • ClusterServiceIntegrationTest.recordsTypeWhatTheToolDescriptionTellsTheModelToRead on real SolrCloud: the replica is active, leader is true, node_name equals the live node, type is NRT, and base_url / router are kept. The existing JSON-path tests pass unchanged apart from leader now being a boolean.
  • McpClientIntegrationTestBase.getClusterStatusWritesTheRecordsAsSolrsShape (HTTP and STDIO), through Spring AI's serialization: no other key, leader is true, node_name and base_url present.
  • ClusterServiceTest.listConfigSets_sortsTheNames.
  • ./gradlew build: 473 tests, 0 failures, 0 skipped.
  • ./gradlew nativeTest -Pnative: 313 successful, 0 failed; the cluster integration tests and both MCP get-cluster-status checks (HTTP and STDIO) pass in the native image. The skipped tests are the @DisabledInNativeImage Mockito tests.

Merge Danger

Door: two-way

Blast Radius: cluster-consumers

leader becomes a boolean, and list-configsets returns {"configSets": [...]} instead of a bare array. Both tools are new in #270, so no released client reads them.

🤖 Generated with Claude Code

adityamparikh and others added 9 commits October 26, 2026 15:22
…ster/status

Every collection tool reports on one collection, so nothing answered
"which replicas are down or recovering, and on which node?" after a
rolling restart or scale event, and nothing listed configsets for
create-collection.

ClusterService adds get-cluster-status (live nodes, every shard and
replica, and an issues list), list-configsets, and a
solr://cluster/status resource. healthy is computed from replica state
and live nodes rather than Solr's own health field, which is computed
before Solr cross-checks replicas against live nodes. ClusterStatusParser
and its records are public so list-fields (apache#241) can reuse the replica
data. The check-health and get-collection-stats descriptions now name
jobs distinct from get-cluster-status.

A new two-node SolrCloud fixture (external ZooKeeper, pinned as
test-image-zookeeper) stops one node and checks that every replica on
it is reported with its node.

Closes apache#223

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
get-cluster-status and solr://cluster/status now return the cluster
section of the response through NamedList.asMap instead of a
server-side model. The response shape is the same on Solr 9.4, 9.9,
9.10 and 10.0, and Solr already marks a replica whose node left
live_nodes as down, so there was nothing for the MCP server to
normalize or recompute.

The only thing Solr gets wrong is health: before 10.1 it is computed
ahead of that live-node correction (SOLR-17820), so a shard can read
GREEN while its only replica is down. The tool description now tells
the model to judge by replica state, and that leader can stay true on
a replica that is down.

This removes ClusterStatusParser, its five records and their native
hints, the node-not-live/no-leader rules, the two-node ZooKeeper
fixture and the test-image-zookeeper pin.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
…ster tools

check-health pings the collection and counts its documents, so it stays
healthy while a replica is down: with one shard of two replicas and one
node dead, queries still succeed. Its description now says it does not
report replica state and names get-cluster-status for that. The
create-collection description names list-configsets for picking a
configSet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
…down

"Stays healthy while a replica is down" was wrong when the down
replica is a shard's only one: the query then fails and check-health
reports unhealthy. It only stays healthy when another replica can
serve the shard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Resolves the McpClientIntegrationTestBase import conflict with apache#275, and
adapts the solr://cluster/status resource to apache#275's removal of JsonUtils:
it now logs the failure and throws a fixed-message IllegalStateException
with no cause instead of returning {"error": <message>}, so SolrJ failure
text (which carries the internal Solr URL) never reaches the client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
When Solr fails, solr://cluster/status must throw the fixed
CLUSTER_STATUS_RESOURCE_ERROR with no cause, since MCP reports the root
cause's message and SolrJ failure text carries the internal Solr URL.
Covers SolrServerException and IOException, the two failures the
resource's getClusterStatus call declares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
get-cluster-status returned CLUSTERSTATUS's cluster section as nested maps
and list-configsets a sorted list of names.

They now return ClusterStatus (collections, live_nodes) with nested
Collection, Shard and Replica records, and ConfigSetList. The records type
what the tool description tells the model to read (replica state, leader,
node_name; shard state and health; collection health and configName) and
compute nothing, so Solr's own values reach the client: the earlier
parser's derived healthy/issues fields are not reintroduced. Every other
property is kept in a @JsonAnySetter / @JsonAnyGetter catch-all and
written back at the same level.

leader, which CLUSTERSTATUS sends as the string "true", is a Boolean.

Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@adityamparikh

Copy link
Copy Markdown
Contributor Author

Folded into #270, whose branch now includes this commit, so get-cluster-status and list-configsets are reviewed once, in their final record form.

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.

1 participant