diff --git a/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index 6e085fe7ebecc..ccda9f98ba468 100644 --- a/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -240,8 +240,11 @@ public ShardSnapshotStatus(String nodeId, State state) { public ShardSnapshotStatus(String nodeId, State state, String reason) { this.nodeId = nodeId; this.state = state; - this.reason = reason; // If the state is failed we have to have a reason for this failure + if (state.failed() && reason == null) { + reason = "failed"; + } + this.reason = reason; assert state.failed() == false || reason != null; } diff --git a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java index 2d4d9fae0754e..29667659cbe65 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java @@ -2706,7 +2706,6 @@ public void testCannotCreateSnapshotsWithSameName() throws Exception { assertThat(createSnapshotResponse.getSnapshotInfo().snapshotId().getName(), equalTo(snapshotName)); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/31054") public void testGetSnapshotsRequest() throws Exception { final String repositoryName = "test-repo"; final String indexName = "test-idx";