|
@@ -1043,21 +1043,8 @@ public class MetadataIndexTemplateService {
|
|
|
|
|
|
/**
|
|
|
* Resolve the given v2 template into an ordered list of aliases
|
|
|
- *
|
|
|
- * @param failIfTemplateHasDataStream Whether to skip validating if a template has a data stream definition and an alias definition.
|
|
|
- * This validation is needed so that no template gets created that creates datastream and also
|
|
|
- * a an alias pointing to the backing indices of a data stream. Unfortunately this validation
|
|
|
- * was missing in versions prior to 7.11, which mean that there are cluster states out there,
|
|
|
- * that have this malformed templates. This method is used when rolling over a data stream
|
|
|
- * or creating new data streams. In order for these clusters to avoid failing these operations
|
|
|
- * immediately after an upgrade the failure should be optional. So that there is time to change
|
|
|
- * these templates. The logic that adds/updates index and component templates shouldn't skip this
|
|
|
- * validation.
|
|
|
*/
|
|
|
- public static List<Map<String, AliasMetadata>> resolveAliases(final Metadata metadata,
|
|
|
- final String templateName,
|
|
|
- // TODO: remove in master after backport to 7.x:
|
|
|
- final boolean failIfTemplateHasDataStream) {
|
|
|
+ public static List<Map<String, AliasMetadata>> resolveAliases(final Metadata metadata, final String templateName) {
|
|
|
final ComposableIndexTemplate template = metadata.templatesV2().get(templateName);
|
|
|
assert template != null : "attempted to resolve aliases for a template [" + templateName +
|
|
|
"] that did not exist in the cluster state";
|
|
@@ -1081,13 +1068,7 @@ public class MetadataIndexTemplateService {
|
|
|
// A template that creates data streams can't also create aliases.
|
|
|
// (otherwise we end up with aliases pointing to backing indices of data streams)
|
|
|
if (aliases.size() > 0 && template.getDataStreamTemplate() != null) {
|
|
|
- if (failIfTemplateHasDataStream) {
|
|
|
- throw new IllegalArgumentException("template [" + templateName + "] has alias and data stream definitions");
|
|
|
- } else {
|
|
|
- String warning = "template [" + templateName + "] has alias and data stream definitions";
|
|
|
- logger.warn(warning);
|
|
|
- HeaderWarning.addWarning(warning);
|
|
|
- }
|
|
|
+ throw new IllegalArgumentException("template [" + templateName + "] has alias and data stream definitions");
|
|
|
}
|
|
|
|
|
|
// Aliases are applied in order, but subsequent alias configuration from the same name is
|
|
@@ -1141,7 +1122,7 @@ public class MetadataIndexTemplateService {
|
|
|
tempIndexService -> {
|
|
|
// Validate aliases
|
|
|
MetadataCreateIndexService.resolveAndValidateAliases(temporaryIndexName, Collections.emptySet(),
|
|
|
- MetadataIndexTemplateService.resolveAliases(stateWithIndex.metadata(), templateName, true), stateWithIndex.metadata(),
|
|
|
+ MetadataIndexTemplateService.resolveAliases(stateWithIndex.metadata(), templateName), stateWithIndex.metadata(),
|
|
|
new AliasValidator(),
|
|
|
// the context is only used for validation so it's fine to pass fake values for the
|
|
|
// shard id and the current timestamp
|