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

[ZDT] create aliases during initial index creation #179783

Closed
pgayvallet opened this issue Apr 2, 2024 · 1 comment · Fixed by #179792
Closed

[ZDT] create aliases during initial index creation #179783

pgayvallet opened this issue Apr 2, 2024 · 1 comment · Fixed by #179792
Assignees
Labels
Feature:Migrations startup-time Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@pgayvallet
Copy link
Contributor

At the moment, we're creating the index and and aliases in different steps, respectively CREATE_TARGET_INDEX and UPDATE_ALIASES.

This was done for simplicity's sake, to keep the index update logic into a single step, given we want to also check/update alias for subsequent migrations (when the indices are already present)

However, for performance's sake, we should now try to optimize our workflow, and have the create operation performed during CREATE_TARGET_INDEX also create the aliases, to avoid one unecessary roundtrip.

Tech pointers

Generating the alias actions that are exposed on state.aliasActions:

const existingAliases = Object.keys(indices[currentIndex].aliases);
const aliasActions = getAliasActions({
existingAliases,
currentIndex,
indexPrefix: context.indexPrefix,
kibanaVersion: context.kibanaVersion,
});

The action that should now use those alias actions:

CREATE_TARGET_INDEX: (state: CreateTargetIndexState) =>
Actions.createIndex({
client,
indexName: state.currentIndex,
mappings: state.indexMappings,
esCapabilities: context.esCapabilities,
}),

Note that getAliasActions technically can return any kind of AliasAction (including deletions), even if today we're only doing additions (and we will likely only do addition for index creation anyway), but we still need some kind of logic to decide if we can extract the alias names from the AliasActions list

@pgayvallet pgayvallet added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:Migrations startup-time labels Apr 2, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@pgayvallet pgayvallet self-assigned this Apr 2, 2024
pgayvallet added a commit that referenced this issue Apr 2, 2024
## Summary

Fix #179783

Create the aliases during initial index creation, instead of doing it in
a later stage. This avoids an additional roundtrip with ES during
project creation.

**Before:** 
```
INIT -> CREATE_TARGET_INDEX -> UPDATE_ALIASES -> INDEX_STATE_UPDATE_DONE -> DONE
```

**After:** 
```
INIT -> CREATE_TARGET_INDEX -> INDEX_STATE_UPDATE_DONE -> DONE
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Migrations startup-time Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants