[8.14] Downsampling test fix: reorder policy and index creation. (#109787)#109791
Merged
elasticsearchmachine merged 1 commit intoelastic:8.14from Jun 17, 2024
Merged
Conversation
…9787) This PR fixes two test failures elastic#103981 & elastic#105437 and refactors the code a bit to make things more explicit. **What was the issue** These tests were creating an index with a policy before that policy was created. This could cause an issue if ILM would run after the index was created but before the policy was created. When ILM runs before the policy is added, the following happen: - the index encounters an error the ILM state sets that the current step is `null`, which makes sense since there is no policy to retrieve a step from. - A `null` step does not qualify to be executed periodically, which also makes sense because probably nothing changed, so chances are the index will remain in this state. - The test keeps waiting for something to happen, but this is not happening because no cluster state updates are coming like they would have if this was a "real" cluster. - Until the test tear down starts, then the index gets updates with the ILM policy but it's a bit too late. The previous scenario is confirmed by the logging too. ``` ----> The index gets created referring a policy that does not exist yet, ILM runs at least twice before the policy is there [2024-06-12T20:14:28,857][....] [index-sanohmhwxl] creating index, ...... [2024-06-12T20:14:28,870][....] [index-sanohmhwxl] retrieved current step key: null [2024-06-12T20:14:28,871][....] unable to retrieve policy [policy-tohpA] for index [index-sanohmhwxl], recording this in step_info for this index java.lang.IllegalArgumentException: policy [policy-tohpA] does not exist -----> Only now the policy is added [2024-06-12T20:14:29,024][....] adding index lifecycle policy [policy-tohpA] -----> ILM is running periodically but because the current step is null it ignores it [2024-06-12T20:15:23,791][....] job triggered: ilm, 1718223323790, 1718223323790 [2024-06-12T20:15:23,791][....] retrieved current step key: null [2024-06-12T20:15:23,791][....] maybe running periodic step (InitializePolicyContextStep) with current step {"phase":"new","action":"init","name":"init"} ``` This can also be locally reproduced by adding a 5s thread sleep before adding the policy. **The fix** Adding a non existing policy to an index is a not a supported path. For this reason, we refactored the test to reflect a more realistic scenario. - We add the policy as an argument in `private void createIndex(String index, String alias, String policy, boolean isTimeSeries)`. This way it's clear that a policy could be added. - We created the policy before adding the index, it does not appear that adding the policy later is crucial for the test, so simplifying it sounded like a good idea. - Simplified `testRollupIndexInTheHotPhaseWithoutRollover` that ensures that a downsampling action cannot be added in the hot phase without rollover. An index is not necessary for this test, so again simplifying it makes the purpose of the test more clear. Fixes: elastic#103981 Fixes: elastic#105437
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports the following commits to 8.14: