-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Saved Objects] Fix document migrator to prevent losing namespaces on import #164848
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on Pierre's comment that create works but import doesn't I didn't expect that the problem was in the internal transform. Although he tested create not bulk_create, it seemed to me like there must be some difference in the payload we pass to bulkCreate from /api/saved_objects/_import vs /api/saved_objects/_bulk_create
https://github.com/elastic/kibana/blob/main/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/create_saved_objects.ts#L123-L127
https://github.com/elastic/kibana/blob/main/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_create.ts#L80-L83
I think it would also be useful to add an API integration test against the _import API for this case.
@rudolf The problem is that we set Line 72 in c288c8b
Before In other words, if we pass |
This reverts commit 897dcc2c77392ac8fd93d83a6e4be7a1964f12dc.
ad5ce9d
to
3e31044
Compare
After some investigation of the nature of the conversion transforms, I found out that there is some inconsistency in conversion transforms. If we import objects with types that have After discussing with @jeramysoucy and digging into the commit history, I found the reason for deferring the conversion transforms. The idea is that the newly created objects or imported should not have After a few attempts at fixing this by changing the flow to apply conversion transform on all the input documents (newly created or imported), that creates unnecessary The best approach would be not to fix this inconsistency at this point, as the With regard to an additional test covering the |
Pinging @elastic/kibana-core (Team:Core) |
💚 Build Succeeded
Metrics [docs]Unknown metric groupsReferences to deprecated APIs
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I tested the scenario described in https://github.com/elastic/sdh-kibana/issues/4101.
Without the fix, the Sample Data Logs dataset gets corrupted upon restart (3 saved objects are moved to the default space).
With the fix, all SO preserve their namespace upon restart.
… import (elastic#164848) (cherry picked from commit ac73d1f)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…aces on import (#164848) (#167372) # Backport This will backport the following commits from `main` to `8.10`: - [[Saved Objects] Fix document migrator to prevent losing namespaces on import (#164848)](#164848) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Michael Dokolin","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-09-19T09:18:45Z","message":"[Saved Objects] Fix document migrator to prevent losing namespaces on import (#164848)","sha":"ac73d1f6b23eca7cad2e92e1a2cd1aae872ad9c4","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["review","Team:Core","Feature:Saved Objects","release_note:skip","Feature:Migrations","backport:prev-minor","v8.11.0"],"number":164848,"url":"https://github.com/elastic/kibana/pull/164848","mergeCommit":{"message":"[Saved Objects] Fix document migrator to prevent losing namespaces on import (#164848)","sha":"ac73d1f6b23eca7cad2e92e1a2cd1aae872ad9c4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164848","number":164848,"mergeCommit":{"message":"[Saved Objects] Fix document migrator to prevent losing namespaces on import (#164848)","sha":"ac73d1f6b23eca7cad2e92e1a2cd1aae872ad9c4"}}]}] BACKPORT--> Co-authored-by: Michael Dokolin <[email protected]>
Summary
Resolves #164454.
Checklist
For maintainers