Skip to content

Commit 225ae14

Browse files
Make use of new Get Snapshots Filtering in SLM Retention (#77423)
We can save ourselves the trouble of even looking at snapshots that don't have a relevant policy on the SLM side now.
1 parent b5a3267 commit 225ae14

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ void getAllRetainableSnapshots(Collection<String> repositories,
238238
// don't time out on this request to not produce failed SLM runs in case of a temporarily slow master node
239239
.setMasterNodeTimeout(TimeValue.MAX_VALUE)
240240
.setIgnoreUnavailable(true)
241+
.setPolicies(policies.toArray(Strings.EMPTY_ARRAY))
241242
.execute(ActionListener.wrap(resp -> {
242243
if (logger.isTraceEnabled()) {
243244
logger.trace("retrieved snapshots: {}",
@@ -252,10 +253,7 @@ void getAllRetainableSnapshots(Collection<String> repositories,
252253
Map<String, List<SnapshotInfo>> snapshots = new HashMap<>();
253254
for (SnapshotInfo info : resp.getSnapshots()) {
254255
if (RETAINABLE_STATES.contains(info.state()) && info.userMetadata() != null) {
255-
final Object policy = info.userMetadata().get(POLICY_ID_METADATA_FIELD);
256-
if (policy instanceof String && policies.contains(policy)) {
257-
snapshots.computeIfAbsent(info.repository(), repo -> new ArrayList<>()).add(info);
258-
}
256+
snapshots.computeIfAbsent(info.repository(), repo -> new ArrayList<>()).add(info);
259257
}
260258
}
261259
listener.onResponse(snapshots);

0 commit comments

Comments
 (0)