diff --git a/docs/changelog/89254.yaml b/docs/changelog/89254.yaml new file mode 100644 index 0000000000000..d86e6fdc3d856 --- /dev/null +++ b/docs/changelog/89254.yaml @@ -0,0 +1,5 @@ +pr: 89254 +summary: Fix message for stalled shutdown +area: Infra/Node Lifecycle +type: bug +issues: [] diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java b/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java index d49d02f582a29..dbde71aeef67c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java @@ -24,6 +24,8 @@ public class ShutdownShardMigrationStatus implements Writeable, ToXContentObject { private static final Version ALLOCATION_DECISION_ADDED_VERSION = Version.V_7_16_0; + public static final String NODE_ALLOCATION_DECISION_KEY = "node_allocation_decision"; + private final SingleNodeShutdownMetadata.Status status; private final long shardsRemaining; @Nullable @@ -83,7 +85,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field("explanation", explanation); } if (Objects.nonNull(allocationDecision)) { - builder.startObject("node_allocation_decision"); + builder.startObject(NODE_ALLOCATION_DECISION_KEY); { allocationDecision.toXContent(builder, params); } diff --git a/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java b/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java index ceda1092f00e6..3d9a38e1ca5da 100644 --- a/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java +++ b/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java @@ -367,9 +367,10 @@ public void testStalledShardMigrationProperlyDetected() throws Exception { ObjectPath.eval("nodes.0.shard_migration.explanation", status), allOf( containsString(indexName), - containsString("cannot move, use the Cluster Allocation Explain API on this shard for details") + containsString("cannot move, see [node_allocation_decision] for details or use the cluster allocation explain API") ) ); + assertThat(ObjectPath.eval("nodes.0.shard_migration.node_allocation_decision", status), notNullValue()); } // Now update the allocation requirements to unblock shard relocation diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java index a87b72eb2ffa1..ceb37f7fdcd46 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java @@ -49,6 +49,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import static org.elasticsearch.cluster.metadata.ShutdownShardMigrationStatus.NODE_ALLOCATION_DECISION_KEY; import static org.elasticsearch.core.Strings.format; public class TransportGetShutdownStatusAction extends TransportMasterNodeAction< @@ -291,10 +292,11 @@ static ShutdownShardMigrationStatus shardMigrationStatus( SingleNodeShutdownMetadata.Status.STALLED, totalRemainingShards, format( - "shard [%s] [%s] of index [%s] cannot move, use the Cluster Allocation Explain API on this shard for details", + "shard [%s] [%s] of index [%s] cannot move, see [%s] for details or use the cluster allocation explain API", shardRouting.shardId().getId(), shardRouting.primary() ? "primary" : "replica", - shardRouting.index().getName() + shardRouting.index().getName(), + NODE_ALLOCATION_DECISION_KEY ), decision );