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

Improve es-archiver saving/loading #118255

Merged
merged 3 commits into from
Nov 11, 2021
Merged

Conversation

jportner
Copy link
Contributor

@jportner jportner commented Nov 10, 2021

Resolves #118209.

This PR makes some changes to the es archiver:

  • Adds the "--keep-index-names" option to the save command, which avoids renaming all .kibana* indices to .kibana_1
    • This is necessary to ensure that v2 migrations run correctly when the archive is loaded, and that documents in the .kibana_task_manager index don't get added to the .kibana index.
  • Adds the "--docs-only" option to the load command, which loads documents from an archive without changing any existing indices.
  • Changes the behavior of "load" so that loading the .kibana_task_manager index alone won't delete other .kibana* indices (currently, the only other one is the main .kibana index)

@jportner jportner added backport:skip This commit does not require backporting v8.1.0 labels Nov 10, 2021
@cla-checker-service
Copy link

cla-checker-service bot commented Nov 10, 2021

💚 CLA has been signed

Copy link
Contributor Author

@jportner jportner left a comment

Choose a reason for hiding this comment

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

Author's notes for reviewers.

It looks like the kbn-es-archiver package has been changed several times over the years to support various edge cases. I aimed to make minimal changes to this so that it will continue to behave the same way for existing usage, but we have the option to modify its behavior for more complex saving/loading.

@@ -75,9 +78,9 @@ function isKibanaIndex(index?: string): index is string {
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't change this code so I can't select the whole block, but it looks like the isKibanaIndex function doesn't match up with the TS doc comment.

The comment says "(e.g. we don't want to remove .kibana_task_manager or the like)", but it looks like the check was later modified to match the .kibana_task_manager index anyway.

At any rate, the change I made modifies the index pattern that is fetched, and isKibanaIndex is only used later to filter the results, so this disparity doesn't really matter in practice. But I thought I'd point it out.

Comment on lines +39 to 43
function createMockClient(responses: SearchResponses) {
// TODO: replace with proper mocked client
const client: any = {
helpers: {
scrollSearch: jest.fn(function* ({ index }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I abstracted this out into a reusable function, but it could/should be improved so I left a TODO here. I wanted to get this PR done with minimal changes so I opted not to change this existing mock logic.

@jportner jportner added the release_note:skip Skip the PR/issue when compiling release notes label Nov 10, 2021
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/es-archiver 12 14 +2
Unknown metric groups

API count

id before after diff
@kbn/es-archiver 25 27 +2

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jportner jportner marked this pull request as ready for review November 10, 2021 23:29
@jportner jportner requested a review from a team as a code owner November 10, 2021 23:29
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the thuroughly working out how to improve the ES Archiver in this case. I assume since you're working with task manager stuff that you're working with Saved Objects which can't be imported/exported with the new kbnServer.importExport API?

@jportner
Copy link
Contributor Author

LGTM, thanks for the thuroughly working out how to improve the ES Archiver in this case.

Sure thing!

I assume since you're working with task manager stuff that you're working with Saved Objects which can't be imported/exported with the new kbnServer.importExport API?

Yeah, 1. some of the objects are not importable/exportable, 2. you can't trigger an index migration on objects that you import through that API.

@jportner jportner merged commit f4b61d0 into elastic:main Nov 11, 2021
@jportner jportner deleted the improve-esarchiver branch November 11, 2021 03:59
@jportner
Copy link
Contributor Author

jportner commented Nov 15, 2021

Looks like es-archiver functionality has diverged enough so that you can't use es-archiver from 8.0 to save documents from 7.16.
So I'll need to backport this.

jportner added a commit to jportner/kibana that referenced this pull request Nov 15, 2021
@spalger spalger removed the backport:skip This commit does not require backporting label Nov 15, 2021
jportner added a commit that referenced this pull request Nov 15, 2021
* Improve es-archiver saving/loading (#118255)

# Conflicts:
#	packages/kbn-es-archiver/src/actions/load.ts
#	packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts
#	packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts
#	packages/kbn-es-archiver/src/lib/indices/kibana_index.ts

* Fix failing unit test

Accidentally deleted some lines when fixing merge conflicts, had to add
them back again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.16.0 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve es-archiver for saving/loading complex sample data
3 participants