Skip to content

GET _cat/snapshots reports total/successful/failed shard counts as 0 for ongoing snapshots #76704

@DaveCTurner

Description

@DaveCTurner

In GET _cat/snapshots we report the shard counts for IN_PROGRESS snapshots as all zeroes, even though we actually know how many of these shards there are and how many of them have succeeded or failed at the point we construct the SnapshotInfo:

diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java
index c6c00451b82..42c8566f98e 100644
--- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java
+++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java
@@ -364,8 +365,10 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo>, ToXContent,
                 Version.CURRENT,
                 entry.startTime(),
                 0L,
-                0,
-                0,
+                entry.shards().size(),
+                Math.toIntExact(StreamSupport.stream(entry.shards().spliterator(), false)
+                    .filter(c -> c.value.state() == SnapshotsInProgress.ShardState.SUCCESS)
+                    .count()),
                 Collections.emptyList(),
                 entry.includeGlobalState(),
                 entry.userMetadata(),

This doesn't actually work, it doesn't distinguish in-progress shards from failed shards, but it's close.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions