-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add rollover-creation-date setting to rolled over index #31144
Conversation
This PR introduces a new index setting `index.rollover.creation_date` much like the `index.creation_date`, it captures the approximate time that the index was rolled over to a new one.
Pinging @elastic/es-core-infra |
Notes for the reviewer:
|
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 do not think that we should use a setting for this. I think that we should have index metadata that captures:
- the alias that was rolled over
- the condition that caused the rollover
- when this occurred
@talevy Can you look into the feasibility of this?
yes @jasontedor , I see no reason this shouldn't be doable. I guess I was just following in line with the resize-settings strategy. you mean to add properties to IndexMetaData class itself to hold this data. Makes sense since it is for internal use when IndexMetaData is available. |
This reverts commit 7817a9f.
This commit introduces a new property to IndexMetaData called RolloverInfo. This object contains a map containing the aliases that were used to rollover the related index, which conditions were met, and at what time the rollover took place.
@@ -64,4 +66,13 @@ public void writeTo(StreamOutput out) throws IOException { | |||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | |||
return builder.field(NAME, value.getStringRep()); | |||
} | |||
|
|||
public static MaxAgeCondition fromXContent(XContentParser parser) throws IOException { | |||
parser.nextToken(); |
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.
what am I doing wrong in parsing that led to me wind up calling this here?
heya @jasontedor, I've updated the PR to introduce the object you recommended. I plan on doing one more iteration on this, but I believe it is ready for initial review. thanks! EDIT: iterations made |
@@ -679,6 +693,8 @@ public Custom read(StreamInput in, String key) throws IOException { | |||
}); | |||
inSyncAllocationIds = DiffableUtils.readImmutableOpenIntMapDiff(in, DiffableUtils.getVIntKeySerializer(), | |||
DiffableUtils.StringSetValueSerializer.getInstance()); | |||
rolloverInfos = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), RolloverInfo::new, |
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.
hmm. these diffs should be behind version checks, right?
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.
It looks pretty good; I left a few comments. They are minor.
@Override | ||
public ClusterState execute(ClusterState currentState) { | ||
RolloverInfo rolloverInfo = new RolloverInfo(rolloverRequest.getAlias(), metConditions, | ||
System.currentTimeMillis()); |
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 think that this should be threadPool.absoluteTimeMillis()
.
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>(); | ||
entries.addAll(NetworkModule.getNamedWriteables()); | ||
entries.addAll(indicesModule.getNamedWriteables()); |
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.
A small nit here; we have the ordering searchModule, indicesModule
for the local variables; can we do the same on the invocation to getNamedWritables
?
@@ -587,6 +595,9 @@ public boolean equals(Object o) { | |||
if (!inSyncAllocationIds.equals(that.inSyncAllocationIds)) { | |||
return false; | |||
} | |||
if (!rolloverInfos.equals(that.rolloverInfos)) { |
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.
== false
(#30697) (I see there are other places in the source that are not like this but they can stay.)
@@ -84,6 +86,9 @@ public void testRollover() throws Exception { | |||
assertFalse(oldIndex.getAliases().containsKey("test_alias")); | |||
final IndexMetaData newIndex = state.metaData().index("test_index-000003"); | |||
assertTrue(newIndex.getAliases().containsKey("test_alias")); | |||
assertThat(oldIndex.getRolloverInfos().size(), equalTo(1)); | |||
assertThat(oldIndex.getRolloverInfos().get("test_alias").getAlias(), equalTo("test_alias")); | |||
assertThat(oldIndex.getRolloverInfos().get("test_alias").getMetConditions(), is(empty())); |
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 think we should make an assertion on the getTime
too. I see a way to do this: take the clock before you submit the request, then assert the value of getTime
is more than that?
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.
true, I guess I was trying avoid timing issues since the system time was being finicky. the move to threadPool makes things more consistent in their world view! thanks
final IndexMetaData oldIndex = client().admin().cluster().prepareState().get().getState().metaData().index("test-1"); | ||
List<Condition> metConditions = oldIndex.getRolloverInfos().get("test_alias").getMetConditions(); | ||
assertThat(metConditions.size(), equalTo(1)); | ||
assertThat(metConditions.get(0).toString(), equalTo(new MaxSizeCondition(maxSizeValue).toString())); |
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.
Let us make an assertion on the clock too.
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.
added
thanks for the round of review, I've addressed your comments and merged-latest-master/removed-unused-imports. thanks @jasontedor! |
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.
LGTM.
thanks! I will probably finalize the back-porting dance early next week in the hopes of not breaking a CI run on a Friday |
* master: Add get stored script and delete stored script to high level REST API - post backport fix Add get stored script and delete stored script to high level REST API (#31355) Core: Combine Action and GenericAction (#31405) Fix reference to XContentBuilder.string() (#31337) Avoid sending duplicate remote failed shard requests (#31313) Fix defaults in GeoShapeFieldMapper output (#31302) RestAPI: Reject forcemerge requests with a body (#30792) Packaging: Remove windows bin files from the tar distribution (#30596) Docs: Use the default distribution to test docs (#31251) [DOCS] Adds testing for security APIs (#31345) Clarify that IP range data can be specified in CIDR notation. (#31374) Use system context for cluster state update tasks (#31241) Percentile/Ranks should return null instead of NaN when empty (#30460) REST high-level client: add validate query API (#31077) Move language analyzers from server to analysis-common module. (#31300) [Test] Fix :example-plugins:rest-handler on Windows Expose lucene's RemoveDuplicatesTokenFilter (#31275) Reload secure settings for plugins (#31383) Remove some cases in FieldTypeLookupTests that are no longer relevant. (#31381) Ensure we don't use a remote profile if cluster name matches (#31331) [TEST] Double write alias fault (#30942) [DOCS] Fix version in SQL JDBC Maven template [DOCS] Improve install and setup section for SQL JDBC SQL: Fix rest endpoint names in node stats (#31371) Support for remote path in reindex api - post backport fix Closes #22913 [ML] Put ML filter API response should contain the filter (#31362) Support for remote path in reindex api (#31290) Add byte array pooling to nio http transport (#31349) Remove trial status info from start trial doc (#31365) [DOCS] Adds links to release notes and highlights add is-write-index flag to aliases (#30942) Add rollover-creation-date setting to rolled over index (#31144) [ML] Hold ML filter items in sorted set (#31338) [Tests] Fix edge case in ScriptedMetricAggregatorTests (#31357)
This commit introduces a new property to IndexMetaData called RolloverInfo. This object contains a map containing the aliases that were used to rollover the related index, which conditions were met, and at what time the rollover took place. much like the `index.creation_date`, it captures the approximate time that the index was rolled over to a new one.
…31144) (#31413) This commit introduces a new property to IndexMetaData called RolloverInfo. This object contains a map containing the aliases that were used to rollover the related index, which conditions were met, and at what time the rollover took place. much like the `index.creation_date`, it captures the approximate time that the index was rolled over to a new one. set version serialization check to 6.4
* 6.x: [DOCS] Omit shard failures assertion for incompatible responses (#31430) [DOCS] Move licensing APIs to docs (#31445) backport of: add is-write-index flag to aliases (#30942) (#31412) backport of: Add rollover-creation-date setting to rolled over index (#31144) (#31413) [Docs] Extend Homebrew installation instructions (#28902) [Docs] Mention ip_range datatypes on ip type page (#31416) Multiplexing token filter (#31208) Fix use of time zone in date_histogram rewrite (#31407) Revert "Mute DefaultShardsIT#testDefaultShards test" [DOCS] Fixes code snippet testing for machine learning (#31189) Security: fix joining cluster with production license (#31341) [DOCS] Updated version in Info API example [DOCS] Moves the info API to docs (#31121) Revert "Increasing skip version for failing test on 6.x" Preserve response headers on cluster update task (#31421) [DOCS] Add code snippet testing for more ML APIs (#31404) Docs: Advice for reindexing many indices (#31279)
This PR introduces a new section to IndexMetaData for storing information about
rollover actions that took place against a specific index.
Information stored
Closes #30887