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

Preserve originId when overwriting existing objects #135358

Merged
merged 5 commits into from
Jun 29, 2022

Conversation

jportner
Copy link
Contributor

@jportner jportner commented Jun 28, 2022

Related to #135346 (partially resolves this issue).

Overview

If an existing object is being overwritten (via create/bulkCreate), Kibana now preserves its originId field if it has one. This behavior can be overridden by specifying originId: undefined.

I also added validation to ensure that originId is only set for multi-namespace object types (it would basically have no effect for single-namespace object types, but we shouldn't allow it).

Testing

  1. Start Kibana
  2. Add sample data
  3. Create "Another" space
  4. Copy a dashboard to Another space using the "Check for existing objects" option
  5. In Another space, make a change to the dashboard and save it
  6. In the Default space, copy the dashboard again using the "Check for existing objects" option
  7. Observe that there are is still only one copy of the dashboard in Another space, and you can examine it to verify it still has the originId field

Additional info

This does not attempt to "repair" any saved objects that have had their originId field cleared out, it can be done in a separate PR, see the linked issue for more details.

@jportner jportner added release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Saved Objects v8.4.0 labels Jun 28, 2022
If an existing object is being overwritten (via create/bulkCreate),
Kibana now preserves its originId field if it has one. This
behavior can be overridden by specifying `originId: undefined`.

I also added validation to ensure that originId is only set for
multi-namespace object types (it would basically have no effect for
single-namespace object types, but we shouldn't allow it).
@jportner jportner force-pushed the issue-135346-preserve-originId branch from b991228 to ba4ca89 Compare June 28, 2022 18:56
@jportner jportner marked this pull request as ready for review June 28, 2022 18:59
@jportner jportner requested a review from a team as a code owner June 28, 2022 18:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

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.

I'm not sure why FTR configs are failing but changes LGTM as a partial fix.

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for jumping on this so quickly ❤️

@jportner
Copy link
Contributor Author

I'm not sure why FTR configs are failing but changes LGTM as a partial fix.

This PR adds validation to prevent consumers from setting the originId field unless the object is share-capable or shareable (e.g., "multi-namespace").

The importSavedObjects module gives consumers the option to create new copies of objects with random IDs, and that blindly sets originId: undefined for all objects that are being imported. So I had to change that case to omit the originId field entirely instead of just setting it to undefined.

@jportner jportner enabled auto-merge (squash) June 28, 2022 21:10
@jportner jportner added the auto-backport Deprecated - use backport:version if exact versions are needed label Jun 28, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.3

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

Questions ?

Please refer to the Backport tool documentation

@jportner jportner deleted the issue-135346-preserve-originId branch June 29, 2022 04:14
kibanamachine added a commit that referenced this pull request Jun 29, 2022
@bataya0
Copy link

bataya0 commented Jun 30, 2022

@geekpete I think this is relevant to the work your doing.

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 Feature:Saved Objects release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.3.1 v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants