From 0860d1dc74bbcd21bd68c25e0cf1b07395153d8f Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 4 May 2020 12:22:06 +0200 Subject: [PATCH] Remove Dead Code in SLM Delete Handling (#56081) (#56098) The delete response is always acknowledged. No need to handle anything else. --- .../xpack/core/slm/history/SnapshotHistoryItem.java | 5 ----- .../elasticsearch/xpack/slm/SnapshotRetentionTask.java | 9 ++------- .../xpack/slm/SnapshotRetentionTaskTests.java | 1 - 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryItem.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryItem.java index 380eaa8a651..6a3836d065c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryItem.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryItem.java @@ -116,11 +116,6 @@ public class SnapshotHistoryItem implements Writeable, ToXContentObject { return new SnapshotHistoryItem(timestamp, policyId, repository, snapshotName, DELETE_OPERATION, true, null, null); } - public static SnapshotHistoryItem deletionPossibleSuccessRecord(long timestamp, String snapshotName, String policyId, String repository, - String details) { - return new SnapshotHistoryItem(timestamp, policyId, repository, snapshotName, DELETE_OPERATION, true, null, details); - } - public static SnapshotHistoryItem deletionFailureRecord(long timestamp, String snapshotName, String policyId, String repository, Exception exception) throws IOException { String exceptionString = exceptionToString(exception); diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java index 8c54943c5a2..52fba7eaf6a 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java @@ -383,14 +383,9 @@ public class SnapshotRetentionTask implements SchedulerEngine.Listener { // i.e are newer or equal to SnapshotsService#MULTI_DELETE_VERSION deleteSnapshot(policyId, repo, info.snapshotId(), slmStats, ActionListener.wrap(acknowledgedResponse -> { deleted.incrementAndGet(); - if (acknowledgedResponse.isAcknowledged()) { - historyStore.putAsync(SnapshotHistoryItem.deletionSuccessRecord(Instant.now().toEpochMilli(), + assert acknowledgedResponse.isAcknowledged(); + historyStore.putAsync(SnapshotHistoryItem.deletionSuccessRecord(Instant.now().toEpochMilli(), info.snapshotId().getName(), policyId, repo)); - } else { - SnapshotHistoryItem.deletionPossibleSuccessRecord(Instant.now().toEpochMilli(), - info.snapshotId().getName(), policyId, repo, - "deletion request issued successfully, no acknowledgement received"); - } }, e -> { failed.incrementAndGet(); try { diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotRetentionTaskTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotRetentionTaskTests.java index b799a3c00b1..cd34f1f644b 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotRetentionTaskTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotRetentionTaskTests.java @@ -473,7 +473,6 @@ public class SnapshotRetentionTaskTests extends ESTestCase { threadPool); AtomicBoolean onFailureCalled = new AtomicBoolean(false); - AtomicReference errHandlerCalled = new AtomicReference<>(null); task.deleteSnapshot("policy", "foo", new SnapshotId("name", "uuid"), new SnapshotLifecycleStats(0, 0, 0, 0, new HashMap<>()), new ActionListener() { @Override