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

Emit deprecation warning if multiple v1 templates match with a new index #55558

Merged
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
setup:
- skip:
features: allowed_warnings
- do:
indices.put_template:
name: index_template
Expand All @@ -18,6 +20,8 @@ setup:
type: keyword

- do:
allowed_warnings:
- "index [test-0] matches multiple templates [global, index_template], and won't be supported with v2 index templates"
bulk:
refresh: true
body:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateInd
final List<IndexTemplateMetadata> v1Templates = MetadataIndexTemplateService.findV1Templates(currentState.metadata(),
request.index(), isHiddenFromRequest);

if (v1Templates.size() > 1) {
deprecationLogger.deprecatedAndMaybeLog("index_template_multiple_match", "index [{}] matches multiple templates " +
"[{}], and won't be supported with v2 index templates", request.index(),
probakowski marked this conversation as resolved.
Show resolved Hide resolved
v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", ")));
}

return applyCreateIndexRequestWithV1Templates(currentState, request, silent, v1Templates, metadataTransformer);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ public void testRolloverMaintainsSetting() throws Exception {
resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23"));
client().admin().indices().prepareDelete(INDEX + "*").get();
}

assertWarnings("index [index-000002] matches multiple templates [one_shard_index_template, random-soft-deletes-template, v1], " +
"and won't be supported with v2 index templates");
}

private void assertUsedV1() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
setup:
- skip:
features: headers
features:
- headers
- allowed_warnings
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
Content-Type: application/json
allowed_warnings:
- "index [.ml-meta] matches multiple templates [.ml-meta, global], and won't be supported with v2 index templates"
index:
index: .ml-meta
id: filter_imposter-filter
Expand Down Expand Up @@ -320,6 +324,8 @@ setup:
indices.delete:
index: ".ml-meta"
- do:
allowed_warnings:
- "index [.ml-meta] matches multiple templates [.ml-meta, global], and won't be supported with v2 index templates"
indices.create:
index: ".ml-meta"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
setup:
- skip:
features: headers
features:
- headers
- allowed_warnings
- do:
allowed_warnings:
- "index [.ml-inference-000002] matches multiple templates [.ml-inference-000002, global], and won't be supported with v2 index templates"
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
setup:
- skip:
features: headers
features:
- headers
- allowed_warnings
- do:
allowed_warnings:
- "index [foo_rollup] matches multiple templates [global, test], and won't be supported with v2 index templates"
indices.create:
index: foo
body:
Expand Down Expand Up @@ -272,6 +276,8 @@ setup:
type: keyword

- do:
allowed_warnings:
- "index [foo_rollup] matches multiple templates [global, test], and won't be supported with v2 index templates"
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
rollup.put_job:
Expand Down