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

Create data stream aliases from template #73867

Merged
merged 27 commits into from
Jul 22, 2021

Conversation

danhermann
Copy link
Contributor

Allows the creation of data stream aliases from a data stream template.

Relates to #66163

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Contributor Author

danhermann commented Jul 16, 2021

@martijnvg, I have data stream aliases being created from templates in this PR. I did it using only the AliasMetadata class without using the o.e.cluster.metadata.DataStreamAlias class which works as long as we're willing to overload or rename some of the members of AliasMetadata to refer to indices or data streams. If you think this is a good approach, I'll go ahead and add some tests and get it ready for final review.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @danhermann, I think this pr is in the right direction, but I think we maybe can simplify even more (see 2 comments).

@@ -51,8 +52,11 @@
@Nullable
private final Boolean isHidden;

@Nullable
private final Boolean isDataStream;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this field is needed? I also don't see that is currently is used in this pr.
In MetadataCreateDataStreamService, data stream aliases can be created without this information? The fact that a DataStreamTemplate is defined should be sufficient?

}

private final boolean hidden;

@Nullable
private final Map<String, AliasMetadata> aliases;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can reuse the alias definitions in ComposableIndexTemplate (defined inside the Template class)?
If a composable index template has a DataStreamTemplate and aliases definitions are present then data stream aliases are created. If just alias definitions are present in composable index template then indices aliases are created.

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/part-2

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left 2 small comments, LGTM otherwise 👍.

Map<String, AliasMetadata> aliases = new HashMap<>(aliasCount);
for (int k = 0; k < aliasCount; k++) {
final String aliasName = randomAlphaOfLength(6);
aliases.put(aliasName, AliasMetadata.newAliasMetadataBuilder(aliasName).build());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also test the case here with aliases with write data streams and filter? (Either by randomly adding and asserting it or a new test)

@@ -222,6 +221,13 @@ static ClusterState createDataStream(MetadataCreateIndexService metadataCreateIn
logger.info("adding data stream [{}] with write index [{}] and backing indices [{}]", dataStreamName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe enhance this log line with the fact that aliases were created as well (if template has aliases)?

@danhermann
Copy link
Contributor Author

Thanks, @martijnvg. I made those changes.

@danhermann danhermann merged commit 0232675 into elastic:master Jul 22, 2021
@danhermann danhermann deleted the 66163_create_alias_from_template branch July 22, 2021 18:12
danhermann added a commit to danhermann/elasticsearch that referenced this pull request Jul 22, 2021
jrodewig added a commit that referenced this pull request Jul 26, 2021
With #73867, you can use component and index templates to add data stream
aliases.
elasticsearchmachine pushed a commit to elasticsearchmachine/elasticsearch that referenced this pull request Jul 26, 2021
…c#75688)

With elastic#73867, you can use component and index templates to add data stream
aliases.
elasticsearchmachine added a commit that referenced this pull request Jul 26, 2021
#75700)

With #73867, you can use component and index templates to add data stream
aliases.

Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request Jul 30, 2021
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request Jul 30, 2021
…c#75688)

With elastic#73867, you can use component and index templates to add data stream
aliases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Data streams Data streams and their lifecycles >non-issue Team:Data Management Meta label for data/management team v7.15.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants