This change fixes problem with updating Index Templates V2. Validatation added in #54933 didn't filter list of conflicting templates correctly so new template was always clashing with itself unless patterns were not changed completely.
This commit is contained in:
parent
41748f02a5
commit
6e1b958069
|
@ -341,6 +341,7 @@ public class MetadataIndexTemplateService {
|
|||
|
||||
Map<String, List<String>> overlaps = findConflictingV2Templates(currentState, name, template.indexPatterns(), true,
|
||||
template.priority());
|
||||
overlaps.remove(name);
|
||||
if (overlaps.size() > 0) {
|
||||
String error = String.format(Locale.ROOT, "index template [%s] has index patterns %s matching patterns from " +
|
||||
"existing templates [%s] with patterns (%s) that have the same priority [%d], multiple index templates may not " +
|
||||
|
|
|
@ -358,6 +358,25 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
|||
assertNotNull(state.metadata().templatesV2().get("bar"));
|
||||
}
|
||||
|
||||
public void testUpdateIndexTemplateV2() throws Exception {
|
||||
ClusterState state = ClusterState.EMPTY_STATE;
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
IndexTemplateV2 template = IndexTemplateV2Tests.randomInstance();
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo", template);
|
||||
|
||||
assertNotNull(state.metadata().templatesV2().get("foo"));
|
||||
assertTemplatesEqual(state.metadata().templatesV2().get("foo"), template);
|
||||
|
||||
List<String> patterns = new ArrayList<>(template.indexPatterns());
|
||||
patterns.add("new-pattern");
|
||||
template = new IndexTemplateV2(patterns, template.template(), template.composedOf(), template.priority(), template.version(),
|
||||
template.metadata());
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo", template);
|
||||
|
||||
assertNotNull(state.metadata().templatesV2().get("foo"));
|
||||
assertTemplatesEqual(state.metadata().templatesV2().get("foo"), template);
|
||||
}
|
||||
|
||||
public void testRemoveIndexTemplateV2() throws Exception {
|
||||
IndexTemplateV2 template = IndexTemplateV2Tests.randomInstance();
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
|
|
Loading…
Reference in New Issue