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

[8.8] Refactor KibanaMigrator, improve readability, maintainability and UT (#155693) #158953

Merged
merged 8 commits into from
Jun 3, 2023

Conversation

gsoldevila
Copy link
Contributor

Backport

This will backport the following commits from main to 8.8:

Questions ?

Please refer to the Backport tool documentation

…lastic#155693)

Addresses the following feedback:
elastic#154151 (comment)

Similar to what has been done for ZDT, the goal of this PR is to extract
the logic of the `runV2Migration()` from the `KibanaMigrator` into a
separate file.

The PR also fixes some incomplete / incorrect UTs and adds a few missing
ones.

(cherry picked from commit 06c337f)

# Conflicts:
#	packages/core/saved-objects/core-saved-objects-migration-server-internal/src/kibana_migrator.test.ts
#	packages/core/saved-objects/core-saved-objects-migration-server-internal/src/kibana_migrator.ts
#	packages/core/saved-objects/core-saved-objects-migration-server-internal/src/run_resilient_migrator.ts
#	src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_test_kit.ts
@TinaHeiligers TinaHeiligers requested review from TinaHeiligers, rudolf, afharo, jloleysens and a team and removed request for rudolf, afharo, jloleysens and TinaHeiligers June 2, 2023 17:17
Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

tiny nits but these don't need to go into this PR. I can go back after the fact and fix them.

options.logger.debug(`migrationVersion: ${migrationVersion} saved object type: ${type}`);
});

// build a indexTypesMap from the info present in tye typeRegistry, e.g.:
Copy link
Contributor

Choose a reason for hiding this comment

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

typo:

Suggested change
// build a indexTypesMap from the info present in tye typeRegistry, e.g.:
// build a indexTypesMap from the info present in typeRegistry, e.g.:


// build a list of all migrators that must be started
const migratorIndices = new Set(Object.keys(indexMap));
// indices involved in a relocation might no longer be present in current mappings
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit: This sentence is confusing to me.

Suggested change
// indices involved in a relocation might no longer be present in current mappings
// the types in indices involved in relocation might not have mappings in the current mappings anymore


// compare indexTypesMap with the one present (or not) in the .kibana index meta
// and check if some SO types have been moved to different indices
const indicesWithMovingTypes = await getIndicesInvolvedInRelocation({
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consistent naming

Suggested change
const indicesWithMovingTypes = await getIndicesInvolvedInRelocation({
const indicesWithRelocatingTypes = await getIndicesInvolvedInRelocation({

@TinaHeiligers
Copy link
Contributor

@gsoldevila From what I can see, the failures are from a type issue:
runOnNonMigratorNodes is declared in run_v2_migrations.test.ts and kibana_migrator.test.ts SO service config and the SO service config schema doesn't include it:

zdt: schema.object({
metaPickupSyncDelaySec: schema.number({ min: 1, defaultValue: 120 }),
}),

@TinaHeiligers TinaHeiligers self-requested a review June 2, 2023 20:13
@gsoldevila
Copy link
Contributor Author

@gsoldevila From what I can see, the failures are from a type issue: runOnNonMigratorNodes is declared in run_v2_migrations.test.ts and kibana_migrator.test.ts SO service config and the SO service config schema doesn't include it:

zdt: schema.object({
metaPickupSyncDelaySec: schema.number({ min: 1, defaultValue: 120 }),
}),

Thanks for the heads up! It seems like I backported that property and I shouldn't have. Fixing

@gsoldevila gsoldevila merged commit a82751c into elastic:8.8 Jun 3, 2023
@kibana-ci
Copy link
Collaborator

💚 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/core-saved-objects-base-server-internal 52 54 +2

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/core-saved-objects-base-server-internal 9 8 -1
Unknown metric groups

API count

id before after diff
@kbn/core-saved-objects-base-server-internal 72 75 +3

ESLint disabled line counts

id before after diff
enterpriseSearch 17 19 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 18 20 +2
securitySolution 480 484 +4
total +6

History

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

@gsoldevila
Copy link
Contributor Author

Feedback addressed in #158940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants