Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix message for stalled shutdown #89254

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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