-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Conversation
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.
Pinging @elastic/es-core-infra |
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 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 |
I've opened #30887 to discuss |
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
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.