Conversation
|
Hi @grcevski, I've created a changelog YAML for you. |
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
…csearch into operator/index_templates
andreidan
left a comment
There was a problem hiding this comment.
Thanks for working on this Nikola
This looks great, I've left a few very minor suggestions
...usterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java
Outdated
Show resolved
Hide resolved
| /** | ||
| * This {@link ReservedClusterStateHandler} is responsible for reserved state | ||
| * CRUD operations on composable index templates and component templates, e.g. file based settings. | ||
| * <p> | ||
| * Internally it uses {@link MetadataIndexTemplateService} to add, update and delete both composable | ||
| * index templates and component templates. The reserved state handler is implemented as a joint handler | ||
| * for both component templates and composable index templates, because of the inherent interdependencies | ||
| * of the two separate types. For example, one cannot create composable index templates without first the | ||
| * component definitions being in the cluster state, however, the opposite is true when deleting. This | ||
| * circular dependency makes it impossible for separation of the two handlers. | ||
| */ |
| public static String componentName(String name) { | ||
| return COMPONENT_PREFIX + name; | ||
| } | ||
|
|
||
| public static String nameFromComponentName(String name) { | ||
| assert name.startsWith(COMPONENT_PREFIX); | ||
| return name.substring(COMPONENT_PREFIX.length()); | ||
| } | ||
|
|
||
| public static String composableIndexName(String name) { | ||
| return COMPOSABLE_PREFIX + name; | ||
| } | ||
|
|
||
| public static String nameFromComposableIndexName(String name) { | ||
| assert name.startsWith(COMPOSABLE_PREFIX); | ||
| return name.substring(COMPOSABLE_PREFIX.length()); | ||
| } |
There was a problem hiding this comment.
Can we maybe document the purpose of these prefixes? It was a bit trappy for me to identify why we do this PREFIX concatenation and parsing.
Maybe componentName can become reservedComponentName ? And nameFromComponentName -> componentNameFromReservedName? (or something along those lines)
| return ClusterState.builder(currentState).metadata(Metadata.builder(currentState.metadata()).put(name, finalIndexTemplate)).build(); | ||
| } | ||
|
|
||
| public Map<String, List<String>> v2TemplateOverlaps( |
There was a problem hiding this comment.
Shall we document this method and since it's now called explicitly maybe add a test in MetadataIndexTemplateServiceTests ?
There was a problem hiding this comment.
Great suggestion, let me do that!
…state/service/ComponentTemplatesFileSettingsIT.java Fix double wording. Co-authored-by: Andrei Dan <andrei.dan@elastic.co>
…csearch into operator/index_templates
|
@grcevski A final question that just dawned on me. How are we handling existing clusters that might have component/composable templates that start with the chosen prefix for the reserved templates? |
I don't think it should be a problem, nothing should happen to the templates, but maybe I'm missing a case here. Essentially we only add the prefix when we store the names of the templates in the reserved cluster state section of the metadata, the templates themselves get stored in the custom storage without the prefix. To store any reserved state we must have defined a template in the file settings, otherwise there's nothing that modifies the reserved sections of the cluster state metadata. Here's what I think the potential situations might be:
This was a very good call-out, I'm going to write some tests to see if I can break the logic and cause a conflict where there shouldn't be one if the user had already used our prefix in the name of a template. |
|
@grcevski thanks so much for the detailed explanation and extra tests 🚀 ❤️ Just toyed around a bit with upgrading an |
This PR adds support for /_index_template/ and /_component_template/ in file based settings.
Relates to #89183