Skip to content

Commit ccdc80c

Browse files
committed
Fix message for stalled shutdown (elastic#89254)
Today if a node shutdown is stalled due to unmoveable shards then we say to use the allocation explain API to find details. In fact, since elastic#78727 we include the allocation explanation in the response already so we should tell users just to look at that instead. This commit adjusts the message to address this.
1 parent 995b32a commit ccdc80c

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

docs/changelog/89254.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 89254
2+
summary: Fix message for stalled shutdown
3+
area: Infra/Node Lifecycle
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
public class ShutdownShardMigrationStatus implements Writeable, ToXContentObject {
2525
private static final Version ALLOCATION_DECISION_ADDED_VERSION = Version.V_7_16_0;
2626

27+
public static final String NODE_ALLOCATION_DECISION_KEY = "node_allocation_decision";
28+
2729
private final SingleNodeShutdownMetadata.Status status;
2830
private final long shardsRemaining;
2931
@Nullable
@@ -83,7 +85,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
8385
builder.field("explanation", explanation);
8486
}
8587
if (Objects.nonNull(allocationDecision)) {
86-
builder.startObject("node_allocation_decision");
88+
builder.startObject(NODE_ALLOCATION_DECISION_KEY);
8789
{
8890
allocationDecision.toXContent(builder, params);
8991
}

x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,10 @@ public void testStalledShardMigrationProperlyDetected() throws Exception {
367367
ObjectPath.eval("nodes.0.shard_migration.explanation", status),
368368
allOf(
369369
containsString(indexName),
370-
containsString("cannot move, use the Cluster Allocation Explain API on this shard for details")
370+
containsString("cannot move, see [node_allocation_decision] for details or use the cluster allocation explain API")
371371
)
372372
);
373+
assertThat(ObjectPath.eval("nodes.0.shard_migration.node_allocation_decision", status), notNullValue());
373374
}
374375

375376
// Now update the allocation requirements to unblock shard relocation

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.concurrent.atomic.AtomicInteger;
5050
import java.util.stream.Collectors;
5151

52+
import static org.elasticsearch.cluster.metadata.ShutdownShardMigrationStatus.NODE_ALLOCATION_DECISION_KEY;
5253
import static org.elasticsearch.core.Strings.format;
5354

5455
public class TransportGetShutdownStatusAction extends TransportMasterNodeAction<
@@ -291,10 +292,11 @@ static ShutdownShardMigrationStatus shardMigrationStatus(
291292
SingleNodeShutdownMetadata.Status.STALLED,
292293
totalRemainingShards,
293294
format(
294-
"shard [%s] [%s] of index [%s] cannot move, use the Cluster Allocation Explain API on this shard for details",
295+
"shard [%s] [%s] of index [%s] cannot move, see [%s] for details or use the cluster allocation explain API",
295296
shardRouting.shardId().getId(),
296297
shardRouting.primary() ? "primary" : "replica",
297-
shardRouting.index().getName()
298+
shardRouting.index().getName(),
299+
NODE_ALLOCATION_DECISION_KEY
298300
),
299301
decision
300302
);

0 commit comments

Comments
 (0)