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

Make use of new Get Snapshots Filtering in SLM Retention #77423

Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,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 @@ -252,10 +253,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