Add rollover-creation-date setting to rolled over index#31144
Add rollover-creation-date setting to rolled over index#31144talevy merged 17 commits intoelastic:masterfrom
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:
|
jasontedor
left a comment
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| public static MaxAgeCondition fromXContent(XContentParser parser) throws IOException { | ||
| parser.nextToken(); |
There was a problem hiding this comment.
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 |
| }); | ||
| inSyncAllocationIds = DiffableUtils.readImmutableOpenIntMapDiff(in, DiffableUtils.getVIntKeySerializer(), | ||
| DiffableUtils.StringSetValueSerializer.getInstance()); | ||
| rolloverInfos = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), RolloverInfo::new, |
There was a problem hiding this comment.
hmm. these diffs should be behind version checks, right?
jasontedor
left a comment
There was a problem hiding this comment.
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.
I think that this should be threadPool.absoluteTimeMillis().
| IndicesModule indicesModule = new IndicesModule(Collections.emptyList()); | ||
| List<NamedWriteableRegistry.Entry> entries = new ArrayList<>(); | ||
| entries.addAll(NetworkModule.getNamedWriteables()); | ||
| entries.addAll(indicesModule.getNamedWriteables()); |
There was a problem hiding this comment.
A small nit here; we have the ordering searchModule, indicesModule for the local variables; can we do the same on the invocation to getNamedWritables?
| if (!inSyncAllocationIds.equals(that.inSyncAllocationIds)) { | ||
| return false; | ||
| } | ||
| if (!rolloverInfos.equals(that.rolloverInfos)) { |
There was a problem hiding this comment.
== false (#30697) (I see there are other places in the source that are not like this but they can stay.)
| 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.
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.
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.
Let us make an assertion on the clock too.
|
thanks for the round of review, I've addressed your comments and merged-latest-master/removed-unused-imports. thanks @jasontedor! |
|
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