-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Migrate watcher to system indices infrastructure #67588
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
Migrate watcher to system indices infrastructure #67588
Conversation
x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java
Outdated
Show resolved
Hide resolved
Pinging @elastic/es-core-features (Team:Core/Features) |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
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
@elasticmachine update branch |
There's something very peculiar going on here. As far as I can tell:
|
I think the issue is that watches have dynamic objects within the mapping including metadata among others. So when the watch is stored with metadata then the mappings need to be updated to account for the In order to resolve this, I think a change is needed to how mappings are validated. If a mapping contains dynamic fields then any fields contained within that object should be allowed. Make sense? |
@elasticmachine update branch |
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.
From Watcher side LGTM. I did left a question for my own understanding.
@@ -597,57 +595,6 @@ public void onIndexModule(IndexModule module) { | |||
module.addIndexOperationListener(listener); | |||
} | |||
|
|||
static void validAutoCreateIndex(Settings settings, Logger logger) { |
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.
👍 (never liked this logic here)
builder.field("dynamic", "strict"); | ||
{ | ||
builder.startObject("_meta"); | ||
builder.field("version", Version.CURRENT); |
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.
The current template doesn't have a version
field under they _meta
object.
If I read the code correctly in SystemIndexManager
this means that irregardless of that, a mapping update will be triggered?
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.
@martijnvg it turns out that the SystemIndexManager
would never have updated the mappings, because without a value for _metadata.version
, the manager would always think that the version was the latest (because Version.fromString(null)
returns Version.CURRENT
). I've pushed a fix for that case.
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.
Thanks for fixing that!
`SystemIndexManager.readMappingVersion` didn't take into account that calling `Version.readString(null)` would return `Version.CURRENT`, which would mean that an index with version metadata would never have its mappings updated. Change the logic to return `Version.EMPTY` in this case, so that the mappings will be updated.
086ebdf
to
ce2d550
Compare
Part of elastic#61656. Migrate the `.watches` and `.triggered_watches` system indices to use the auto-create infrastructure. The watcher history indices are left alone. As part of this work, a `SystemIndexDescriptor` now inspects its mappings to determine whether it has any dynamic mappings. This influences how strict Elasticsearch is with enforcing the descriptor's mappings, since ES cannot know in advanced what all the mappings will be. This PR also fixes the `SystemIndexManager` so that (1) it doesn't fall over when attempting to inspect the state of an index that hasn't been created yet, and (2) does update mappings if there's no version field in the mapping metadata.
Backport of #67588. Part of #61656. Migrate the `.watches` and `.triggered_watches` system indices to use the auto-create infrastructure. The watcher history indices are left alone. As part of this work, a `SystemIndexDescriptor` now inspects its mappings to determine whether it has any dynamic mappings. This influences how strict Elasticsearch is with enforcing the descriptor's mappings, since ES cannot know in advanced what all the mappings will be. This PR also fixes the `SystemIndexManager` so that (1) it doesn't fall over when attempting to inspect the state of an index that hasn't been created yet, and (2) does update mappings if there's no version field in the mapping metadata.
Since #67588, .triggered_watches and .watches indices are no longer created on node startup. This PR removing them from the warnings for comparison.
Since elastic#67588, .triggered_watches and .watches indices are no longer created on node startup. This PR removing them from the warnings for comparison.
Since elastic#67588, .triggered_watches and .watches indices are no longer created on node startup. This PR removing them from the warnings for comparison.
We moved watcher to run on the system indices infrastructure in elastic#67588. This commit makes sure Watcher cleans up the legacy templates it used before it was migrated to system indices.
Part of #61656.
Migrate the
.watches
and.triggered_watches
system indices to use the auto-create infrastructure. The watcher history indices are left alone.As part of this work, a
SystemIndexDescriptor
now inspects its mappings to determine whether it has any dynamic mappings. This influences how strict Elasticsearch is with enforcing the descriptor's mappings, since ES cannot know in advanced what all the mappings will be.This PR also fixes the
SystemIndexManager
so that it doesn't fall over when attempting to inspect the state of an index that hasn't been created yet.