Skip to content

Commit 94b2df5

Browse files
committed
Only the current master reports snapshots in progress
1 parent c04e9ed commit 94b2df5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4457,9 +4457,14 @@ private SnapshotsInProgress createSnapshot(
44574457
}
44584458

44594459
private Collection<LongWithAttributes> getSnapshotsInProgress() {
4460-
final SnapshotsInProgress snapshotsInProgress = SnapshotsInProgress.get(clusterService.state());
4460+
final ClusterState currentState = clusterService.state();
4461+
// Only the master should report on snapshots-in-progress
4462+
if (currentState.nodes().isLocalNodeElectedMaster() == false) {
4463+
return List.of();
4464+
}
4465+
final SnapshotsInProgress snapshotsInProgress = SnapshotsInProgress.get(currentState);
44614466
final List<LongWithAttributes> snapshotsInProgressMetrics = new ArrayList<>();
4462-
clusterService.state().metadata().projects().forEach((projectId, project) -> {
4467+
currentState.metadata().projects().forEach((projectId, project) -> {
44634468
RepositoriesMetadata repositoriesMetadata = RepositoriesMetadata.get(project);
44644469
if (repositoriesMetadata != null) {
44654470
repositoriesMetadata.repositories().forEach(repository -> {

0 commit comments

Comments
 (0)