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

Refactor KibanaMigrator, improve readability, maintainability and UT #155693

Merged

Conversation

gsoldevila
Copy link
Contributor

Addresses the following feedback:
#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.

@gsoldevila gsoldevila added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc enhancement New value added to drive a business result technical debt Improvement of the software architecture and operational architecture release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Feature:Migrations v8.8.0 labels Apr 25, 2023
@gsoldevila gsoldevila requested a review from a team as a code owner April 25, 2023 09:35
@elasticmachine
Copy link
Contributor

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

@gsoldevila gsoldevila requested a review from a team as a code owner April 26, 2023 15:20
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.

nice cleanup!
LGTM

// .kibana_task_manager migrator is NOT involved in relocation, must not sync
expect(logs).toMatch('[.kibana_task_manager] LEGACY_REINDEX_WAIT_FOR_TASK -> LEGACY_DELETE.');
expect(logs).toMatch('[.kibana_task_manager] CREATE_REINDEX_TEMP');
// .kibana_task_manager migrator is NOT involved in relocation, must not sync with others
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for leaving that comment here!

@@ -69,4 +69,4 @@ export type {
SavedObjectAttributes,
SavedObjectAttributeSingle,
SavedObjectReference,
} from '@kbn/core-saved-objects-common/src/server_types';
Copy link
Contributor

Choose a reason for hiding this comment

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

You're importing the client-side, deprecated versions by doing so.

Copy link
Contributor Author

@gsoldevila gsoldevila May 31, 2023

Choose a reason for hiding this comment

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

Nice catch, will undo these changes!

@gsoldevila gsoldevila removed the request for review from a team May 31, 2023 17:38
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #43 / endpoint When on the Endpoint Policy Details Page and the save button is clicked should persist update on the screen

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 59 61 +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 11 10 -1
Unknown metric groups

API count

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

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 415 419 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 499 503 +4
total +6

History

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

@gsoldevila gsoldevila merged commit 06c337f into elastic:main Jun 1, 2023
@rudolf rudolf added the Epic:ScaleMigrations Scale upgrade migrations to millions of saved objects label Jun 2, 2023
@gsoldevila
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

gsoldevila added a commit to gsoldevila/kibana that referenced this pull request Jun 2, 2023
…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
gsoldevila added a commit that referenced this pull request Jun 3, 2023
…nd UT (#155693) (#158953)

# Backport

This will backport the following commits from `main` to `8.8`:
- [Refactor KibanaMigrator, improve readability, maintainability and UT
(#155693)](#155693)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Gerard
Soldevila","email":"gerard.soldevila@elastic.co"},"sourceCommit":{"committedDate":"2023-06-01T12:47:40Z","message":"Refactor
KibanaMigrator, improve readability, maintainability and UT
(#155693)\n\nAddresses the following
feedback:\r\nhttps://github.com//pull/154151#discussion_r1158470566\r\n\r\nSimilar
to what has been done for ZDT, the goal of this PR is to extract\r\nthe
logic of the `runV2Migration()` from the `KibanaMigrator` into
a\r\nseparate file.\r\n\r\nThe PR also fixes some incomplete / incorrect
UTs and adds a few
missing\r\nones.","sha":"06c337f903a5b310f8a21a66065b186bbbc9642e","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","enhancement","technical
debt","release_note:skip","backport:skip","Feature:Migrations","Epic:KBNA-7838","v8.9.0"],"number":155693,"url":"#155693
KibanaMigrator, improve readability, maintainability and UT
(#155693)\n\nAddresses the following
feedback:\r\nhttps://github.com//pull/154151#discussion_r1158470566\r\n\r\nSimilar
to what has been done for ZDT, the goal of this PR is to extract\r\nthe
logic of the `runV2Migration()` from the `KibanaMigrator` into
a\r\nseparate file.\r\n\r\nThe PR also fixes some incomplete / incorrect
UTs and adds a few
missing\r\nones.","sha":"06c337f903a5b310f8a21a66065b186bbbc9642e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"#155693
KibanaMigrator, improve readability, maintainability and UT
(#155693)\n\nAddresses the following
feedback:\r\nhttps://github.com//pull/154151#discussion_r1158470566\r\n\r\nSimilar
to what has been done for ZDT, the goal of this PR is to extract\r\nthe
logic of the `runV2Migration()` from the `KibanaMigrator` into
a\r\nseparate file.\r\n\r\nThe PR also fixes some incomplete / incorrect
UTs and adds a few
missing\r\nones.","sha":"06c337f903a5b310f8a21a66065b186bbbc9642e"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
sloanelybutsurely pushed a commit to sloanelybutsurely/kibana that referenced this pull request Jun 6, 2023
…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.
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 enhancement New value added to drive a business result Epic:ScaleMigrations Scale upgrade migrations to millions of saved objects Feature:Migrations 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 technical debt Improvement of the software architecture and operational architecture v8.8.1 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants