-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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 ignore_missing_component_templates
config option
#92436
Merged
dakrone
merged 39 commits into
elastic:main
from
ruflin:ignore-missing-component-template
Jan 31, 2023
Merged
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
866dbbd
Add `ignore_missing_component_tempaltes` config option
ruflin 5aaa91b
Merge branch 'main' into ignore-missing-component-template
ruflin 3befa9b
adjust from bool to ignore_missing_component_templates as an array
ruflin 21ca694
update unit tests
ruflin d4a6c31
add one more constructor to keep old behaviour
ruflin 5b8a46f
Merge branch 'main' into ignore-missing-component-template
ruflin ab46b1b
fix some unit tests
ruflin 64e141f
add basic tests
ruflin 1a18d50
remove not needed test
ruflin 0512edf
Merge branch 'main' into ignore-missing-component-template
ruflin 5dd2ee7
fixing test cases
ruflin c28b24b
add documentation
ruflin 9c68539
add more docs
ruflin 1cd0127
add code reviews for docs
ruflin 29a34fb
add JSON to source blocks
ruflin 71ae211
apply formatting rules
ruflin 23559c0
fix tests, cleanup log message
ruflin 0374941
Update docs/changelog/92436.yaml
ruflin 91b1837
Update docs/reference/indices/ignore-missing-component-templates.asci…
ruflin d5ff03a
Update docs/reference/indices/ignore-missing-component-templates.asci…
ruflin 54c4a3d
Update docs/reference/indices/ignore-missing-component-templates.asci…
ruflin 84c4a57
update docs with review and add random tests
ruflin 9e40dd3
add null test for component template
ruflin 157ba01
add issue reference to changelog
ruflin 7fa7ab8
add failing rest test
ruflin 824be38
try another fix for the rest tests
ruflin 1d84c00
push enhanced test to catch error and then check for index template
ruflin 7a66bf3
fix changelog area entry
ruflin cc9cc5c
fix yaml test
ruflin 1de49ca
Update rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/in…
ruflin 973c49f
Update server/src/test/java/org/elasticsearch/cluster/metadata/Compos…
ruflin 072c81a
add initial pr review cleanup
ruflin da7e66d
update more tests
ruflin cc824c5
remove comment from changelog and remove old exception code
ruflin 2bb57f5
cleanup code / spotless
ruflin f12afe8
fix yaml test to use indices again
ruflin 57a9ce9
Merge branch 'main' into ignore-missing-component-template
ruflin 55ef4bc
fix import after merge
ruflin 0f64578
Merge branch 'main' into ignore-missing-component-template
ruflin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pr: 92436 | ||
summary: Add `ignore_missing_component_templates` config option | ||
# The bot was creating `area: "Data streams, Indices APIs"` but this seems to be invalid | ||
area: Indices APIs | ||
type: enhancement | ||
issues: | ||
- 92426 |
95 changes: 95 additions & 0 deletions
95
docs/reference/indices/ignore-missing-component-templates.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
[[ignore_missing_component_templates]] | ||
== Config ignore_missing_component_templates | ||
|
||
The configuration option `ignore_missing_component_templates` can be used when an index template references a component template that might not exist. Every time a data stream is created based on the index template, the existence of the component template will be checked. If it exists, it will used to form the index's composite settings. If it does not exist, it is ignored. | ||
|
||
=== Usage example | ||
|
||
In the following, one component template and an index template are created. The index template references two component templates, but only the `@package` one exists. | ||
|
||
|
||
Create the component template `logs-foo_component1`. This has to be created before the index template as it is not optional: | ||
|
||
[source,console] | ||
---- | ||
PUT _component_template/logs-foo_component1 | ||
{ | ||
"template": { | ||
"mappings": { | ||
"properties": { | ||
"host.name": { | ||
"type": "keyword" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
---- | ||
|
||
Next, the index template will be created and it references two component templates: | ||
|
||
[source,JSON] | ||
---- | ||
"composed_of": ["logs-foo_component1", "logs-foo_component2"] | ||
---- | ||
|
||
Before, only the `logs-foo_component1` compontent template was created, meaning the `logs-foo_component2` is missing. Because of this the following entry was added to the config: | ||
|
||
[source,JSON] | ||
---- | ||
"ignore_missing_component_templates": ["logs-foo_component2"], | ||
---- | ||
|
||
During creation of the template, it will not validate that `logs-foo_component2` exists: | ||
|
||
|
||
[source,console] | ||
---- | ||
PUT _index_template/logs-foo | ||
{ | ||
"index_patterns": ["logs-foo-*"], | ||
"data_stream": { }, | ||
"composed_of": ["logs-foo_component1", "logs-foo_component2"], | ||
"ignore_missing_component_templates": ["logs-foo_component2"], | ||
"priority": 500 | ||
} | ||
---- | ||
// TEST[continued] | ||
|
||
The index template `logs-foo` was successfully created. A data stream can be created based on this template: | ||
|
||
[source,console] | ||
---- | ||
PUT _data_stream/logs-foo-bar | ||
---- | ||
// TEST[continued] | ||
|
||
Looking at the mappings of the data stream, it will contain the `host.name` field. | ||
|
||
At a later stage, the missing component template might be added: | ||
|
||
[source,console] | ||
---- | ||
PUT _component_template/logs-foo_component2 | ||
{ | ||
"template": { | ||
"mappings": { | ||
"properties": { | ||
"host.ip": { | ||
"type": "ip" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
---- | ||
// TEST[continued] | ||
|
||
This will not have an immediate effect on the data stream. The mapping `host.ip` will only show up in the data stream mappings when the data stream is rolled over automatically next time or a manual rollover is triggered: | ||
|
||
[source,console] | ||
---- | ||
POST logs-foo-bar/_rollover | ||
---- | ||
// TEST[continued] | ||
ruflin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TEST[teardown:data_stream_cleanup] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@dakrone I'll remove this line but maybe worth someone checks on why this is happening. It seems the bot can't handle 2 labels well (or the other way around).
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.
That's because PRs only support a single green label, so the entry does not get duplicated in the changelog. This change would be indices APIs more than data streams (you don't have to change the labels, since you fixed this.)