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

SO migrations: Improves transformation error creation and testing #100297

Conversation

TinaHeiligers
Copy link
Contributor

@TinaHeiligers TinaHeiligers commented May 18, 2021

Summary

Enhances the work on saved object migrations done in #96986.
Resolves #99685

Changes/improvements handled:

  • Use the originalError's message as the top level TransformSavedObjectDocumentError message.
  • Refactors extractTransformFailuresReason to construct the full, final migration failure reason.
  • Integration test improvements:
    • Uses a 7.13.0 index to test the changes introduced to REINDEX_SOURCE_TO_TEMP_*.
    • Ensures we get all the failed document ids in the logs along with the full failure reason.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@TinaHeiligers TinaHeiligers 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 Feature:Saved Objects v8.0.0 v7.14.0 project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient labels May 18, 2021
failedDoc,
error
);
throw new TransformSavedObjectDocumentError(failedTransform, failedDoc, error);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have the raw doc id in migrateRawDocsSafely and don't need the extra properties.

Doc: failedDoc"
`
);
expect(err.message).toMatchInlineSnapshot(`"Dang diggity!"`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use the original transformation error message and don't construct one anymore.

@elastic elastic deleted a comment from kibanamachine May 18, 2021
@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

@TinaHeiligers TinaHeiligers force-pushed the so-migrationsv2/transform-failures-test-enhance branch from f056e34 to 8d81a96 Compare May 18, 2021 23:17
@elastic elastic deleted a comment from kibanamachine May 19, 2021
].length
).toEqual(16);
}
await expect(root.start()).rejects.toThrowError();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't use the old approach? Reading from the logs adds flakiness (logging nondeterminism, the test depends on the logging format, etc.)

Copy link
Contributor Author

@TinaHeiligers TinaHeiligers May 19, 2021

Choose a reason for hiding this comment

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

FWIW, I was trying to avoid parsing strings to get the details.
I'll change it back to read from the error message itself if that's more reliable.

"Failed to transform document smelly. Transform: dog:1.2.3
Doc: {\\"id\\":\\"smelly\\",\\"type\\":\\"dog\\",\\"attributes\\":{},\\"migrationVersion\\":{}}"
`);
expect(error.message).toMatchInlineSnapshot(`"Dang diggity!"`);
expect(error).toBeInstanceOf(TransformSavedObjectDocumentError);
Copy link
Contributor Author

@TinaHeiligers TinaHeiligers May 19, 2021

Choose a reason for hiding this comment

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

@mshustov after we've aded in the raw SO doc id in migrateRawDocsSafely we push the original error and the rawId on to the array of transformErrors within migrateRawDocsSafely. We assert this in migrate_raw_docs.test.

We also have the rawId for failed transformations in the final migration error (as part of the reason) that's shown to the end user when a migration fails because of document transformation issues.

I could specifically add an assertion to the integration test to show that we do get the raw id. It would require a bit of string parsing though, because each transform error also contains the stack trace. I'll add one but can't think of a way to make the parsing elegant.

Copy link
Contributor

Choose a reason for hiding this comment

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

We also have the rawId for failed transformations in the final migration error (as part of the reason) that's shown to the end user when a migration fails because of document transformation issues.

Do we know rawId value? If so, we can check that a message contains rawId value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we know the rawId value?

We don't know the rawId value in document_migrator, only the uuid part of it.

@@ -1184,7 +1177,7 @@ describe('migrations v2 model', () => {
expect(newState.reason.includes('Migrations failed. Reason:')).toBe(true);
expect(newState.reason.includes('Corrupt saved object documents: ')).toBe(true);
expect(newState.reason.includes('Transformation errors: ')).toBe(true);
expect(newState.reason.includes('randomvis: 7.12.0')).toBe(true);
expect(newState.reason.includes('bob:tail')).toBe(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asserts that we have the raw document id in the error message

@TinaHeiligers TinaHeiligers requested review from mshustov and a team May 20, 2021 13:05
@TinaHeiligers TinaHeiligers added the auto-backport Deprecated - use backport:version if exact versions are needed label May 21, 2021
@TinaHeiligers TinaHeiligers enabled auto-merge (squash) May 21, 2021 23:07
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

References to deprecated APIs

id before after diff
canvas 29 25 -4
maps 286 208 -78
total -82

History

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

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

@TinaHeiligers TinaHeiligers deleted the so-migrationsv2/transform-failures-test-enhance branch May 22, 2021 01:24
kibanamachine added a commit that referenced this pull request May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed enhancement New value added to drive a business result 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.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance saved objects migrations collect failing docs implementation
4 participants