* Emit deprecation warning if multiple v1 templates match with a new index (#55558) * Emit deprecation warning if multiple v1 templates match with a new index * DEPRECATION_LOGGER rename
This commit is contained in:
parent
fc6422ffcc
commit
797f63e743
|
@ -1,4 +1,6 @@
|
||||||
setup:
|
setup:
|
||||||
|
- skip:
|
||||||
|
features: allowed_warnings
|
||||||
- do:
|
- do:
|
||||||
indices.put_template:
|
indices.put_template:
|
||||||
name: index_template
|
name: index_template
|
||||||
|
@ -18,6 +20,8 @@ setup:
|
||||||
type: keyword
|
type: keyword
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
|
allowed_warnings:
|
||||||
|
- "index [test-0] matches multiple v1 templates [global, index_template], v2 index templates will only match a single index template"
|
||||||
bulk:
|
bulk:
|
||||||
refresh: true
|
refresh: true
|
||||||
body:
|
body:
|
||||||
|
|
|
@ -342,6 +342,12 @@ public class MetadataCreateIndexService {
|
||||||
final List<IndexTemplateMetadata> v1Templates = MetadataIndexTemplateService.findV1Templates(currentState.metadata(),
|
final List<IndexTemplateMetadata> v1Templates = MetadataIndexTemplateService.findV1Templates(currentState.metadata(),
|
||||||
request.index(), isHiddenFromRequest);
|
request.index(), isHiddenFromRequest);
|
||||||
|
|
||||||
|
if (v1Templates.size() > 1) {
|
||||||
|
DEPRECATION_LOGGER.deprecatedAndMaybeLog("index_template_multiple_match", "index [{}] matches multiple v1 templates " +
|
||||||
|
"[{}], v2 index templates will only match a single index template", request.index(),
|
||||||
|
v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", ")));
|
||||||
|
}
|
||||||
|
|
||||||
return applyCreateIndexRequestWithV1Templates(currentState, request, silent, v1Templates, metadataTransformer);
|
return applyCreateIndexRequestWithV1Templates(currentState, request, silent, v1Templates, metadataTransformer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,9 @@ public class TemplatePreferenceIT extends ESSingleNodeTestCase {
|
||||||
resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23"));
|
resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23"));
|
||||||
client().admin().indices().prepareDelete(INDEX + "*").get();
|
client().admin().indices().prepareDelete(INDEX + "*").get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assertWarnings("index [index-000002] matches multiple v1 templates [one_shard_index_template, " +
|
||||||
|
"random-soft-deletes-template, v1], v2 index templates will only match a single index template");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUsedV1() {
|
private void assertUsedV1() {
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
---
|
---
|
||||||
setup:
|
setup:
|
||||||
- skip:
|
- skip:
|
||||||
features: headers
|
features:
|
||||||
|
- headers
|
||||||
|
- allowed_warnings
|
||||||
- do:
|
- do:
|
||||||
headers:
|
headers:
|
||||||
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
allowed_warnings:
|
||||||
|
- "index [.ml-meta] matches multiple v1 templates [.ml-meta, global], v2 index templates will only match a single index template"
|
||||||
index:
|
index:
|
||||||
index: .ml-meta
|
index: .ml-meta
|
||||||
id: filter_imposter-filter
|
id: filter_imposter-filter
|
||||||
|
@ -320,6 +324,8 @@ setup:
|
||||||
indices.delete:
|
indices.delete:
|
||||||
index: ".ml-meta"
|
index: ".ml-meta"
|
||||||
- do:
|
- do:
|
||||||
|
allowed_warnings:
|
||||||
|
- "index [.ml-meta] matches multiple v1 templates [.ml-meta, global], v2 index templates will only match a single index template"
|
||||||
indices.create:
|
indices.create:
|
||||||
index: ".ml-meta"
|
index: ".ml-meta"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
setup:
|
setup:
|
||||||
- skip:
|
- skip:
|
||||||
features: headers
|
features:
|
||||||
|
- headers
|
||||||
|
- allowed_warnings
|
||||||
- do:
|
- do:
|
||||||
|
allowed_warnings:
|
||||||
|
- "index [.ml-inference-000002] matches multiple v1 templates [.ml-inference-000002, global], v2 index templates will only match a single index template"
|
||||||
headers:
|
headers:
|
||||||
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
||||||
index:
|
index:
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
setup:
|
setup:
|
||||||
- skip:
|
- skip:
|
||||||
features: headers
|
features:
|
||||||
|
- headers
|
||||||
|
- allowed_warnings
|
||||||
- do:
|
- do:
|
||||||
|
allowed_warnings:
|
||||||
|
- "index [foo_rollup] matches multiple v1 templates [global, test], v2 index templates will only match a single index template"
|
||||||
indices.create:
|
indices.create:
|
||||||
index: foo
|
index: foo
|
||||||
body:
|
body:
|
||||||
|
@ -273,6 +277,8 @@ setup:
|
||||||
type: keyword
|
type: keyword
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
|
allowed_warnings:
|
||||||
|
- "index [foo_rollup] matches multiple v1 templates [global, test], v2 index templates will only match a single index template"
|
||||||
headers:
|
headers:
|
||||||
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
||||||
rollup.put_job:
|
rollup.put_job:
|
||||||
|
|
Loading…
Reference in New Issue