Skip to content

inherit [index.lifecycle.date] from rolled-over time #30853

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

Merged
merged 13 commits into from
Jun 21, 2018

Conversation

talevy
Copy link
Contributor

@talevy talevy commented May 25, 2018

Indices that are rolled over preserve their origin index.lifecycle.date
as the time the index was created. Although this is also fine, it would
make more sense to start the timer for moving to the warm phase from the
time it was rolled over so that we capture the time elapsed from the
latest data, as opposed to when the index was created.

This commit adds an extra step within the RolloverAction that
extracts the index.creation_date of the newly created index from the RolloverStep
and sets that as the index.lifecycle.date of the rolled-over index that is
waiting for its next phase.

Indices that are rolled over preserve their origin index.lifecycle.date
as the time the index was created. Although this is also fine, it would
make more sense to start the timer for moving to the warm phase from the
time it was rolled over so that we capture the time elapsed from the
latest data, as opposed to when the index was created.

This commit adds an extra step within the RolloverAction that
extracts the index.creation_date of the newly created index from the RolloverStep
and sets that as the index.lifecycle.date of the rolled-over index that is
waiting for its next phase.
@talevy talevy added the :Data Management/ILM+SLM Index and Snapshot lifecycle management label May 25, 2018
@talevy talevy requested a review from colings86 May 25, 2018 00:16
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@colings86
Copy link
Contributor

I can see a potential issue with this approach. There is no guarantee that the set will run while the next index has the alias. In normal execution this is technically true but unlikely but it becomes more likely if the user sets index.lifecycle.skip on the index after the rollover step completes but before this step runs. In that case there is a scenario where the rollover of the next index happens before the index is un-skipped and it will write the wrong timestamp to the index. We need to make sure that the timestamp is always correct since if we add the wrong timestamp it affects the index for the entire of its lifetime.

I wonder if we should instead modifying the TransportRolloverAction so as well as changing the alias to the new index it also writes a setting to the old index to indicate when it was rolled-over? This seems like a generally useful piece of information to the user even outside the scope of ILM. That way we can have this step work much like the InitializePolicyContextStep where it just takes the timestamp from that new setting and sets it on the index.lifecycle.date setting.

@talevy
Copy link
Contributor Author

talevy commented May 25, 2018

I've opened #30887 to discuss

@talevy
Copy link
Contributor Author

talevy commented Jun 18, 2018

Hi @colings86, I've updated this PR to leverage RolloverInfo

import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;

public class UpdateRolloverLifecycleDateStep extends AsyncActionStep {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should have this as an async action step or have it work directly on the cluster state update thread like PolicyInitialisationStep does? It seems strange to me that we set this setting on the cluster state update thread initially and then later as an async action step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, it was a reflex for updating settings... but this setting is controlled by us and safe to do on the cluster-state 👍

Copy link
Contributor

@colings86 colings86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment bbut LGTM

@@ -11,13 +11,14 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;

public class InitializePolicyContextStep extends Step {
public class InitializePolicyContextStep extends ClusterStateActionStep {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this step is special and we rely on it definitely running as is I think wee should make it final.

Actually I think we should make all the steps final but that can be in a different change. I think its most important that this one is final as we need to ensure the creation date is definitely set properly

@talevy talevy merged commit fc2f982 into elastic:index-lifecycle Jun 21, 2018
@talevy talevy deleted the ilm-rollover-date branch June 21, 2018 14:18
jasontedor pushed a commit that referenced this pull request Aug 17, 2018
Indices that are rolled over preserve their origin index.lifecycle.date
as the time the index was created. Although this is also fine, it would
make more sense to start the timer for moving to the warm phase from the
time it was rolled over so that we capture the time elapsed from the
latest data, as opposed to when the index was created.

This commit adds an extra step within the RolloverAction that
extracts the index.creation_date of the newly created index from the RolloverStep
and sets that as the index.lifecycle.date of the rolled-over index that is
waiting for its next phase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/ILM+SLM Index and Snapshot lifecycle management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants