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

[Discuss] Referential integrity with Saved Objects #71453

Closed
streamich opened this issue Jul 13, 2020 · 9 comments
Closed

[Discuss] Referential integrity with Saved Objects #71453

streamich opened this issue Jul 13, 2020 · 9 comments
Labels
discuss impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Meta Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@streamich
Copy link
Contributor

streamich commented Jul 13, 2020

TLDR; This thread is to discuss extending Saved Objects service to add referential integrity.


Right now referential integrity in Kibana is not enforced. For example, you can delete a visualization, which is used by one or more dashboards, and those dashboards will render with empty panels for that visualization, as the visualization is not removed from the dashboards. Another example is you can have alerts that reference non-existing actions. One more example, is you can have a Dashboard drilldown that references a deleted dashboard.

Some ideas:

  • Saved Object service could provide a delete method which checks if it is "safe to delete" that saved object, i.e. it has no other objects referencing it. Delete would fail if a saved object is referenced by one or more other saved objects.
  • Saved Objects service could provide a first class way to retrieve all objects referencing your object. (Currently, it is also possible but is not part of Saved Objects service API).
  • Not sure if we need it in Kibana, but there could be an option to execute cascading delete — it would delete the object you are trying to delete and all other objects referencing it, if any, recursively.

Related:

@streamich streamich added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team:AppArch Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! labels Jul 13, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@elasticmachine
Copy link
Contributor

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

@streamich streamich added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Jul 13, 2020
@rudolf
Copy link
Contributor

rudolf commented Jul 14, 2020

I believe the security team is looking to implement this as part of #27004 although it's unclear from that issue exactly when that's planned.

@legrego
Copy link
Member

legrego commented Jul 14, 2020

Referential integrity checks would be part of phase 3 if I'm not mistaken (we are currently on Phase 1.5). It's important to note that this will be a best-effort check. It won't be possible to guarantee that references will always be correct.

@jportner
Copy link
Contributor

Our planned work for "referential integrity checks" is only to support converting (existing) single-namespace types to (new) multi-namespace types.
So that means ensuring references stay intact during the conversion process itself, along with during import and copy.
I view the ideas described above as complementary to that.

  • Saved Object service could provide a delete method which checks if it is "safe to delete" that saved object, i.e. it has no other objects referencing it. Delete would fail if a saved object is referenced by one or more other saved objects.

WRT multi-namespace objects: fortunately, we changed "Delete" so it only removes the object from the current Space. In a nutshell, this check is not more complex for multi-namespace objects, because we only have to check references in the current Space 👍

The other way an object may get deleted is when an entire Space is deleted (deleteByNamespace operation), but that uses a different deleteByQuery cluster call so it should be unaffected.

  • Saved Objects service could provide a first class way to retrieve all objects referencing your object. (Currently, it is also possible but is not part of Saved Objects service API).

I like this idea (I've been calling these "inbound references" while working with them)

@pgayvallet
Copy link
Contributor

I think this all makes a lot of sense.

Saved Object service could provide a delete method which checks if it is "safe to delete" that saved object, i.e. it has no other objects referencing it. Delete would fail if a saved object is referenced by one or more other saved objects.

We could simply add a safeDelete=false option to SavedObjectsDeleteOptions. When true, it would check for potential parent references before performing the delete and fails if any is found.

Saved Objects service could provide a first class way to retrieve all objects referencing your object. (Currently, it is also possible but is not part of Saved Objects service API).

AFAIK it's pretty simple, at least for single namespaced SO, it's a plain

client.find({
    hasReference: { type, id }
})

So exposing this a public API should be easy. Just need to be cautious regarding namespace scope: Do we want/need to be able to retrieve referencing objects from all namespaces, or always ONLY from the current one?

Not sure if we need it in Kibana, but there could be an option to execute cascading delete — it would delete the object you are trying to delete and all other objects referencing it, if any, recursively.

Ah, the famous cascade delete in a non-transactional world. Been there, done that with mongo. Would wait to have an actual use case to open this discussion imho, as error handling in the middle of the cascade is something I wouldn't want my worse enemy to have to implement.

@streamich streamich mentioned this issue Feb 24, 2021
13 tasks
@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Jun 21, 2021
@gmmorris gmmorris added the Meta label Jul 2, 2021
@legrego legrego removed the Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! label Aug 3, 2021
@kobelb kobelb added the needs-team Issues missing a team label label Jan 31, 2022
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jan 31, 2022
@ppisljar
Copy link
Member

ppisljar commented Aug 8, 2022

Thank you for contributing to this issue, however, we are closing this issue due to inactivity as part of a backlog grooming effort. If you believe this feature/bug should still be considered, please reopen with a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Meta Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

9 participants