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

Add steps to migrate from a legacy kibana index #82161

Merged
merged 3 commits into from
Nov 6, 2020

Conversation

rudolf
Copy link
Contributor

@rudolf rudolf commented Oct 30, 2020

Summary

Adds additional steps for migrating from a legacy index. The existing legacy reindex algorithm wasn't idempotent. These changes have the following implications:

Unlike the existing migration algorithm, we won't create an alias that points
to the reindexed target. So after migrating a v6 .kibana we'll have
.kibana_pre6.5.0_001 but there will be no .kibana alias or index. This is
because we have no way to ensure that when we try to delete the old
index, we don't accidently delete the newly cloned index with the same
alias. Should this happen we'd completely loose the data in the legacy index.

This algorithm shares a limitation with our existing migration algorithm
(since v7.4). When the task manager index gets reindexed a reindex script is
applied. Because we delete the original task manager index there is no way to
rollback a failed task manager migration without a snapshot.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@rudolf rudolf added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:Saved Objects labels Oct 30, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

1. Mark the legacy index as read-only and wait for all in-flight operations to drain (requires https://github.com/elastic/elasticsearch/pull/58094). This prevents any further writes from outdated nodes. Assuming this API is similar to the existing `/<index>/_close` API, we expect to receive `"acknowledged" : true` and `"shards_acknowledged" : true`. If all shards don’t acknowledge within the timeout, retry the operation until it succeeds.
2. Clone the legacy index into a new index which has writes enabled. Use a fixed index name i.e `.kibana_pre6.5.0_001` or `.kibana_task_manager_pre7.4.0_001`. `POST /.kibana/_clone/.kibana_pre6.5.0_001?wait_for_active_shards=all {"settings": {"index.blocks.write": false}}`. Ignore errors if the clone already exists. Ignore errors if the legacy source doesn't exist.
3. Wait for the cloning to complete `GET /_cluster/health/.kibana_pre6.5.0_001?wait_for_status=green&timeout=60s` If cloning doesn’t complete within the 60s timeout, log a warning for visibility and poll again.
4. Apply the `convertToAlias` script if defined `POST /.kibana_pre6.5.0_001/_update_by_query?conflicts=proceed {"script": {...}}`. The `convertToAlias` script will have to be idempotent, preferably setting `ctx.op="noop"` on subsequent runs to avoid unecessary writes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will require some work to the task manager convertToAliasScript

convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`,
but this should be trivial

@rudolf rudolf requested a review from kobelb October 30, 2020 16:34
@rudolf rudolf added release_note:skip Skip the PR/issue when compiling release notes v7.11.0 v8.0.0 labels Oct 30, 2020
rfcs/text/0013_saved_object_migrations.md Show resolved Hide resolved
@@ -212,39 +212,59 @@ Note:
If none of the aliases exists, this is a new Elasticsearch cluster and no
migrations are necessary. Create the `.kibana_7.10.0_001` index with the
following aliases: `.kibana_current` and `.kibana_7.10.0`.
2. If `.kibana_current` and `.kibana_7.10.0` both exists and are pointing to the same index this version's migration has already been completed.
2. If the source is a < v6.5 `.kibana` index or < 7.4 `.kibana_task_manager`
Copy link
Contributor

@kobelb kobelb Nov 3, 2020

Choose a reason for hiding this comment

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

nit: If the user upgraded from < 5.6 to 6.0, they will have a .kibana alias pointing at a .kibana-6 index. However, if they have a fresh deploy < 6.5, then they'll have a bare .kibana index. I don't think this has any concrete impact on the algorithm that you're proposing; however, it makes the naming of the index a bit imprecise: .kibana_pre6.5.0_001

Source: https://www.elastic.co/guide/en/kibana/6.0/migrating-6.0-index.html contains the manual steps which are equivalent to what the Upgrade Assistant did.

P.S. I'm primarily relaying the information that @tylersmalley gave me on Slack because he's a wealth of knowledge about old upgrades ❤️

rfcs/text/0013_saved_object_migrations.md Outdated Show resolved Hide resolved
@rudolf rudolf merged commit b0eb277 into elastic:master Nov 6, 2020
@rudolf rudolf deleted the so-migrations-rfc-update branch November 6, 2020 10:57
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 10, 2020
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 82161 or prevent reminders by adding the backport:skip label.

1 similar comment
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 82161 or prevent reminders by adding the backport:skip label.

@rudolf rudolf added the backport:skip This commit does not require backporting label Nov 11, 2020
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 11, 2020
@rudolf rudolf added backport missing Added to PRs automatically when the are determined to be missing a backport. and removed v7.11.0 labels Nov 11, 2020
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Saved Objects release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants