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

Debug log the latest saved object migrations per type #89722

Merged
merged 3 commits into from
Feb 2, 2021

Conversation

rudolf
Copy link
Contributor

@rudolf rudolf commented Jan 29, 2021

Summary

Closes: #86320

Adds the following debug logging to make it easier to see which saved object types will be migrated and what the expected migrationVersion should be after the migration was applied:

server    log   [15:10:10.466] [info][savedobjects-service] Starting saved objects migrations
server    log   [15:10:10.479] [debug][savedobjects-service] applying registered migrations for the following saved object types:
server    log   [15:10:10.480] [debug][savedobjects-service] migrationVersion: 6.6.0 saved object type: space
server    log   [15:10:10.481] [debug][savedobjects-service] migrationVersion: 7.0.0 saved object type: canvas-workpad
server    log   [15:10:10.481] [debug][savedobjects-service] migrationVersion: 7.6.0 saved object type: task
server    log   [15:10:10.481] [debug][savedobjects-service] migrationVersion: 7.9.0 saved object type: config
server    log   [15:10:10.481] [debug][savedobjects-service] migrationVersion: 7.9.0 saved object type: infrastructure-ui-source
server    log   [15:10:10.481] [debug][savedobjects-service] migrationVersion: 7.9.3 saved object type: search
server    log   [15:10:10.481] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: map
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: exception-list-agnostic
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: exception-list
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: ingest_manager_settings
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: fleet-agent-actions
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: fleet-agent-events
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: ingest-agent-policies
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: fleet-enrollment-api-keys
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: ml-job
server    log   [15:10:10.482] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: cases-configure
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.10.0 saved object type: cases-user-actions
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: index-pattern
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: graph-workspace
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: dashboard
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: lens
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: action
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: alert
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: cases-comments
server    log   [15:10:10.483] [debug][savedobjects-service] migrationVersion: 7.11.0 saved object type: cases
server    log   [15:10:10.484] [debug][savedobjects-service] migrationVersion: 7.12.0 saved object type: visualization
server    log   [15:10:10.484] [debug][savedobjects-service] migrationVersion: 7.12.0 saved object type: fleet-agents
server    log   [15:10:10.484] [debug][savedobjects-service] migrationVersion: 7.12.0 saved object type: ingest-package-policies

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 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.12.0 project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient labels Jan 29, 2021
@rudolf rudolf requested a review from a team as a code owner January 29, 2021 14:27
@elasticmachine
Copy link
Contributor

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

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

LGTM! Just one question/NIT I'd like to be clear about.

this.log.debug('Applying registered migrations for the following saved object types:');
Object.entries(this.documentMigrator.migrationVersion)
.sort(([t1, v1], [t2, v2]) => {
return Semver.compare(v1, v2);
Copy link
Member

Choose a reason for hiding this comment

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

NIT: are v1 and v2 ensured to always exist? If any don't, can this logic break the rest of the migration logic?

Copy link
Contributor

Choose a reason for hiding this comment

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

The code is hard to follow, but from what I understand, I think that this.documentMigrator.migrationVersion will always have a version, but that types without any migration registered will not be present in the map. Which sounds acceptable @rudolf?

if (!transforms.length) {
return migrations;
}

public get migrationVersion(): SavedObjectsMigrationVersion {
if (!this.migrations) {
throw new Error('Migrations are not ready. Make sure prepareMigrations is called first.');
}
return Object.entries(this.migrations).reduce((acc, [prop, { latestMigrationVersion }]) => {
// some migration objects won't have a latestMigrationVersion (they only contain reference transforms that are applied from other types)
if (latestMigrationVersion) {
return { ...acc, [prop]: latestMigrationVersion };
}
return acc;
}, {});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, these versions come from plugins registering migrations, so it will always be present (and I think we validate that it's a valid semver). If a type doesn't register a migration it won't be in this map.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@rudolf rudolf merged commit 7fbec26 into elastic:master Feb 2, 2021
@rudolf rudolf deleted the debug-log-registered-migrations branch February 2, 2021 09:42
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 4, 2021
@kibanamachine
Copy link
Contributor

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

rudolf added a commit to rudolf/kibana that referenced this pull request Feb 4, 2021
* Debug log the latest saved object migrations per type

* Fix broken test
rudolf added a commit that referenced this pull request Feb 4, 2021
* Debug log the latest saved object migrations per type

* Fix broken test
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Saved Objects project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient 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 v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug logging listing all saved object types with their migration versions
5 participants