Skip to content

Commit

Permalink
Fix message for stalled shutdown (elastic#89254)
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 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.
  • Loading branch information
DaveCTurner committed Aug 11, 2022
1 parent 995b32a commit ccdc80c
Show file tree
Hide file tree
Showing 4 changed files with 14 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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit ccdc80c

Please sign in to comment.