Skip to content

Commit

Permalink
Make use of new Get Snapshots Filtering in SLM Retention (elastic#77423)
Browse files Browse the repository at this point in the history
We can save ourselves the trouble of even looking at snapshots that don't have a relevant
policy on the SLM side now.
  • Loading branch information
original-brownbear committed Oct 17, 2021
1 parent 29c1fcb commit 5a8644b
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void getAllRetainableSnapshots(Collection<String> repositories,
// don't time out on this request to not produce failed SLM runs in case of a temporarily slow master node
.setMasterNodeTimeout(TimeValue.MAX_VALUE)
.setIgnoreUnavailable(true)
.setPolicies(policies.toArray(Strings.EMPTY_ARRAY))
.execute(ActionListener.wrap(resp -> {
if (logger.isTraceEnabled()) {
logger.trace("retrieved snapshots: {}",
Expand All @@ -253,10 +254,7 @@ void getAllRetainableSnapshots(Collection<String> repositories,
Map<String, List<SnapshotInfo>> snapshots = new HashMap<>();
for (SnapshotInfo info : resp.getSnapshots()) {
if (RETAINABLE_STATES.contains(info.state()) && info.userMetadata() != null) {
final Object policy = info.userMetadata().get(POLICY_ID_METADATA_FIELD);
if (policy instanceof String && policies.contains(policy)) {
snapshots.computeIfAbsent(info.repository(), repo -> new ArrayList<>()).add(info);
}
snapshots.computeIfAbsent(info.repository(), repo -> new ArrayList<>()).add(info);
}
}
listener.onResponse(snapshots);
Expand Down

0 comments on commit 5a8644b

Please sign in to comment.