Skip to content

Commit

Permalink
Fix message for stalled shutdown (#89267)
Browse files Browse the repository at this point in the history
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 #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.

Backport of #89254
  • Loading branch information
DaveCTurner authored Aug 11, 2022
1 parent 9010b5c commit d1e8147
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/89254.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 89254
summary: Fix message for stalled shutdown
area: Infra/Node Lifecycle
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import static org.elasticsearch.cluster.metadata.ShutdownShardMigrationStatus.NODE_ALLOCATION_DECISION_KEY;

public class TransportGetShutdownStatusAction extends TransportMasterNodeAction<
GetShutdownStatusAction.Request,
GetShutdownStatusAction.Response> {
Expand Down Expand Up @@ -289,10 +291,11 @@ static ShutdownShardMigrationStatus shardMigrationStatus(
SingleNodeShutdownMetadata.Status.STALLED,
totalRemainingShards,
new ParameterizedMessage(
"shard [{}] [{}] of index [{}] cannot move, use the Cluster Allocation Explain API on this shard for details",
"shard [{}] [{}] of index [{}] cannot move, see [{}] 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
).getFormattedMessage(),
decision
);
Expand Down

0 comments on commit d1e8147

Please sign in to comment.