Skip to content
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

Ensure that .watcher-history-11* template is in installed prior to use #56734

Merged
merged 5 commits into from May 15, 2020

Conversation

jakelandis
Copy link
Contributor

WatcherIndexTemplateRegistry
as of #52962 requires all nodes
to be on 7.7.0 before it allows the version 11 index template to be installed.

While in a mixed cluster, nothing prevents Watcher from running on the new
host before the all of the nodes are on 7.7.0. This will result in the
.watcher-history-11* index without the proper mappings. Without the proper
mapping a single document (for a large watch) can exceed the default 1000 field
limit and cause error to show in the logs.

This commit ensures the same logic for writing to the index is applied as for
installing the template. In a mixed cluster, the 10 index template will continue
to be written. Only once all of nodes are on 7.7.0+ will the 11 index template
be installed and used.

Note - this PR targets 7.x and will be back ported to 7.7.next. This conditional
installation of the template is not present in master.

closes #56732

[WatcherIndexTemplateRegistry](https://github.com/elastic/elasticsearch/blob/7.7/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java#L74)
as of elastic#52962 requires all nodes
to be on 7.7.0 before it allows the version 11 index template to be installed.

While in a mixed cluster, nothing prevents Watcher from running on the new
host before the all of the nodes are on 7.7.0. This will result in the
.watcher-history-11* index without the proper mappings. Without the proper
mapping a single document (for a large watch) can exceed the default 1000 field
limit and cause error to show in the logs.

This commit ensures the same logic for writing to the index is applied as for
installing the template. In a mixed cluster, the `10` index template will continue
to be written. Only once all of nodes are on 7.7.0+ will the `11` index template
be installed and used.

Note - this PR targets 7.x and will be back ported to 7.7.next. This conditional
installation of the template is not present in master.

closes elastic#56732
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Watcher)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label May 14, 2020
@jakelandis
Copy link
Contributor Author

@gwbrown - mind taking a look at this one? It touches some of the areas I know you are familiar with.

Copy link
Contributor

@gwbrown gwbrown left a comment

Choose a reason for hiding this comment

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

Good catch. Thanks for the fix and apologies for the breakage. Left a few relatively minor comments, but this looks like a good fix.

Comment on lines 258 to 260
if (enabled && transportClient == false) {
validAutoCreateIndex(settings, logger, clusterService);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double checking: This doesn't result in different behavior, right? Just makes the failure occur (if it occurs) at a different time during node startup.

(also, my assumption is that this moved because at the time the constructor is called we don't have a cluster state yet, correct?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct, same behavior and moved to allow access the the cluster state.

@jakelandis
Copy link
Contributor Author

jakelandis commented May 15, 2020

@gwbrown thanks for the review, should be ready for another look - changes implemented on 123453c

EDIT: I noticed that the commit starts with 12345, what kind of prize do I win ?

@jakelandis
Copy link
Contributor Author

@elasticmachine update branch

@jakelandis
Copy link
Contributor Author

jakelandis commented May 15, 2020

Test failures look related to attempting to read cluster state too early (specific to this PR)

@jakelandis
Copy link
Contributor Author

Had to remove the conditional logic for the validAutoCreateIndex method. This relevant parts of this method only emits a warning if the auto_create_index setting is too restrictive to create daily indices for the next 6 months. For this case, it is fine (possibly even more correct) to always assume the latest version of the index name. Changes on 7a80068

Copy link
Contributor

@gwbrown gwbrown left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! I agree that only checking the "newest" index name pattern is probably fine, it's very much a best-effort check anyway.

@jakelandis jakelandis merged commit 813609b into elastic:7.x May 15, 2020
@jakelandis jakelandis deleted the fix/56732 branch May 15, 2020 21:29
jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request May 15, 2020
elastic#56734)

WatcherIndexTemplateRegistry as of elastic#52962
requires all nodes to be on 7.7.0 before it allows the version 11 index template to be
installed.

While in a mixed cluster, nothing prevents Watcher from running on the new
host before the all of the nodes are on 7.7.0. This will result in the
.watcher-history-11* index without the proper mappings. Without the proper
mapping a single document (for a large watch) can exceed the default 1000 field
limit and cause error to show in the logs.

This commit ensures the same logic for writing to the index is applied as for
installing the template. In a mixed cluster, the `10` index template will continue
to be written. Only once all of nodes are on 7.7.0+ will the `11` index template
be installed and used.

closes elastic#56732
jakelandis added a commit that referenced this pull request May 15, 2020
… to use (#56734) (#56848)

WatcherIndexTemplateRegistry as of #52962 
requires all nodes to be on 7.7.0 before it allows the version 11 index template to be 
installed.

While in a mixed cluster, nothing prevents Watcher from running on the new
host before the all of the nodes are on 7.7.0. This will result in the
.watcher-history-11* index without the proper mappings. Without the proper
mapping a single document (for a large watch) can exceed the default 1000 field
limit and cause error to show in the logs.

This commit ensures the same logic for writing to the index is applied as for
installing the template. In a mixed cluster, the `10` index template will continue
to be written. Only once all of nodes are on 7.7.0+ will the `11` index template
be installed and used.

closes #56732
jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request May 15, 2020
elastic#56734)

WatcherIndexTemplateRegistry as of elastic#52962 
requires all nodes to be on 7.7.0 before it allows the version 11 index template to be 
installed.

While in a mixed cluster, nothing prevents Watcher from running on the new
host before the all of the nodes are on 7.7.0. This will result in the
.watcher-history-11* index without the proper mappings. Without the proper
mapping a single document (for a large watch) can exceed the default 1000 field
limit and cause error to show in the logs.

This commit ensures the same logic for writing to the index is applied as for
installing the template. In a mixed cluster, the `10` index template will continue
to be written. Only once all of nodes are on 7.7.0+ will the `11` index template
be installed and used.

closes elastic#56732
jakelandis added a commit that referenced this pull request May 26, 2020
… to use (#56734) (#56855)

WatcherIndexTemplateRegistry as of #52962 
requires all nodes to be on 7.7.0 before it allows the version 11 index template to be 
installed.

While in a mixed cluster, nothing prevents Watcher from running on the new
host before the all of the nodes are on 7.7.0. This will result in the
.watcher-history-11* index without the proper mappings. Without the proper
mapping a single document (for a large watch) can exceed the default 1000 field
limit and cause error to show in the logs.

This commit ensures the same logic for writing to the index is applied as for
installing the template. In a mixed cluster, the `10` index template will continue
to be written. Only once all of nodes are on 7.7.0+ will the `11` index template
be installed and used.

closes #56732
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants