Skip to content

Commit 41b4cee

Browse files
Change allocation explain message (#127060)
Reduce the amount of text returned when no shard is requested and all shards are assigned. Less text is easier to digest and hopefully will not be skimmed.
1 parent 584b237 commit 41b4cee

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ public static ShardRouting findShardToExplain(
177177
}
178178
if (foundShard == null) {
179179
throw new IllegalArgumentException(Strings.format("""
180-
No shard was specified in the request which means the response should explain a randomly-chosen unassigned shard, but \
181-
there are no unassigned shards in this cluster. To explain the allocation of an assigned shard you must specify the \
182-
target shard in the request. See %s for more information.""", ReferenceDocs.ALLOCATION_EXPLAIN_API));
180+
There are no unassigned shards in this cluster. Specify an assigned shard in the request body to explain its \
181+
allocation. See %s for more information.""", ReferenceDocs.ALLOCATION_EXPLAIN_API));
183182
}
184183
} else {
185184
if (projectIds.size() != 1) {

server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainActionTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ public void testFindAnyUnassignedShardToExplain() {
196196
).getMessage(),
197197
allOf(
198198
// no point in asserting the precise wording of the message into this test, but we care that it contains these bits:
199-
containsString("No shard was specified in the request"),
200-
containsString("specify the target shard in the request"),
199+
containsString("There are no unassigned shards in this cluster."),
200+
containsString("Specify an assigned shard in the request body"),
201201
containsString("https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-allocation-explain")
202202
)
203203
);

0 commit comments

Comments
 (0)