Skip to content

Commit

Permalink
ILM the delete action waits for a TSDS index time/bounds to lapse (#1…
Browse files Browse the repository at this point in the history
…00207)

This adds the `check-ts-end-time-passed` step to the delete action so,
for time series indices, we wait until they're not meant to accept new
writes anymore before deleting them (i.e. until the time interval the covers
the ingestion for `now` has lapsed)
  • Loading branch information
andreidan authored Oct 4, 2023
1 parent 9c717df commit f32c8f5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/100207.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 100207
summary: ILM the delete action waits for a TSDS index time/bounds to lapse
area: ILM+SLM
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.xcontent.XContentParser;

import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -80,18 +81,39 @@ public boolean isSafeAction() {
@Override
public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey) {
Step.StepKey waitForNoFollowerStepKey = new Step.StepKey(phase, NAME, WaitForNoFollowersStep.NAME);
Step.StepKey waitTimeSeriesEndTimePassesKey = new Step.StepKey(phase, NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
Step.StepKey deleteStepKey = new Step.StepKey(phase, NAME, DeleteStep.NAME);
Step.StepKey cleanSnapshotKey = new Step.StepKey(phase, NAME, CleanupSnapshotStep.NAME);

if (deleteSearchableSnapshot) {
WaitForNoFollowersStep waitForNoFollowersStep = new WaitForNoFollowersStep(waitForNoFollowerStepKey, cleanSnapshotKey, client);
WaitForNoFollowersStep waitForNoFollowersStep = new WaitForNoFollowersStep(
waitForNoFollowerStepKey,
waitTimeSeriesEndTimePassesKey,
client
);
WaitUntilTimeSeriesEndTimePassesStep waitUntilTimeSeriesEndTimeStep = new WaitUntilTimeSeriesEndTimePassesStep(
waitTimeSeriesEndTimePassesKey,
cleanSnapshotKey,
Instant::now,
client
);
CleanupSnapshotStep cleanupSnapshotStep = new CleanupSnapshotStep(cleanSnapshotKey, deleteStepKey, client);
DeleteStep deleteStep = new DeleteStep(deleteStepKey, nextStepKey, client);
return Arrays.asList(waitForNoFollowersStep, cleanupSnapshotStep, deleteStep);
return Arrays.asList(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, cleanupSnapshotStep, deleteStep);
} else {
WaitForNoFollowersStep waitForNoFollowersStep = new WaitForNoFollowersStep(waitForNoFollowerStepKey, deleteStepKey, client);
WaitForNoFollowersStep waitForNoFollowersStep = new WaitForNoFollowersStep(
waitForNoFollowerStepKey,
waitTimeSeriesEndTimePassesKey,
client
);
WaitUntilTimeSeriesEndTimePassesStep waitUntilTimeSeriesEndTimeStep = new WaitUntilTimeSeriesEndTimePassesStep(
waitTimeSeriesEndTimePassesKey,
deleteStepKey,
Instant::now,
client
);
DeleteStep deleteStep = new DeleteStep(deleteStepKey, nextStepKey, client);
return Arrays.asList(waitForNoFollowersStep, deleteStep);
return Arrays.asList(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, deleteStep);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,40 @@ public void testToSteps() {
{
List<Step> steps = DeleteAction.WITH_SNAPSHOT_DELETE.toSteps(null, phase, nextStepKey);
assertNotNull(steps);
assertEquals(3, steps.size());
assertEquals(4, steps.size());
StepKey expectedFirstStepKey = new StepKey(phase, DeleteAction.NAME, WaitForNoFollowersStep.NAME);
StepKey expectedSecondStepKey = new StepKey(phase, DeleteAction.NAME, CleanupSnapshotStep.NAME);
StepKey expectedThirdKey = new StepKey(phase, DeleteAction.NAME, DeleteStep.NAME);
StepKey expectedSecondStepKey = new StepKey(phase, DeleteAction.NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
StepKey expectedThirdKey = new StepKey(phase, DeleteAction.NAME, CleanupSnapshotStep.NAME);
StepKey expectedFourthKey = new StepKey(phase, DeleteAction.NAME, DeleteStep.NAME);
WaitForNoFollowersStep firstStep = (WaitForNoFollowersStep) steps.get(0);
CleanupSnapshotStep secondStep = (CleanupSnapshotStep) steps.get(1);
DeleteStep thirdStep = (DeleteStep) steps.get(2);
WaitUntilTimeSeriesEndTimePassesStep secondStep = (WaitUntilTimeSeriesEndTimePassesStep) steps.get(1);
CleanupSnapshotStep thirdStep = (CleanupSnapshotStep) steps.get(2);
DeleteStep fourthStep = (DeleteStep) steps.get(3);
assertEquals(expectedFirstStepKey, firstStep.getKey());
assertEquals(expectedSecondStepKey, firstStep.getNextStepKey());
assertEquals(expectedSecondStepKey, secondStep.getKey());
assertEquals(expectedThirdKey, thirdStep.getKey());
assertEquals(nextStepKey, thirdStep.getNextStepKey());
assertEquals(expectedFourthKey, thirdStep.getNextStepKey());
assertEquals(expectedFourthKey, fourthStep.getKey());
assertEquals(nextStepKey, fourthStep.getNextStepKey());
}

{
List<Step> steps = DeleteAction.NO_SNAPSHOT_DELETE.toSteps(null, phase, nextStepKey);
StepKey expectedFirstStepKey = new StepKey(phase, DeleteAction.NAME, WaitForNoFollowersStep.NAME);
StepKey expectedSecondStepKey = new StepKey(phase, DeleteAction.NAME, DeleteStep.NAME);
assertEquals(2, steps.size());
StepKey expectedSecondStepKey = new StepKey(phase, DeleteAction.NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
StepKey expectedThirdStepKey = new StepKey(phase, DeleteAction.NAME, DeleteStep.NAME);
assertEquals(3, steps.size());
assertNotNull(steps);
WaitForNoFollowersStep firstStep = (WaitForNoFollowersStep) steps.get(0);
DeleteStep secondStep = (DeleteStep) steps.get(1);
WaitUntilTimeSeriesEndTimePassesStep secondStep = (WaitUntilTimeSeriesEndTimePassesStep) steps.get(1);
DeleteStep thirdStep = (DeleteStep) steps.get(2);
assertEquals(expectedFirstStepKey, firstStep.getKey());
assertEquals(expectedSecondStepKey, firstStep.getNextStepKey());
assertEquals(nextStepKey, secondStep.getNextStepKey());
assertEquals(expectedSecondStepKey, secondStep.getKey());
assertEquals(expectedThirdStepKey, secondStep.getNextStepKey());
assertEquals(expectedThirdStepKey, thirdStep.getKey());
assertEquals(nextStepKey, thirdStep.getNextStepKey());
}
}

Expand Down

0 comments on commit f32c8f5

Please sign in to comment.