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

Storage: Support listing deleted entities #84043

Merged
merged 2 commits into from
Mar 11, 2024
Merged

Conversation

DanCech
Copy link
Collaborator

@DanCech DanCech commented Mar 6, 2024

This PR explores adding support for listing deleted entities by passing a new label selector grafana.app/listDeleted=true

It works by selecting the entries that are added to the entity_history_table when entities are deleted.

I opted to separate it from the regular List function as there are some differences around label selection (we can't use the entity_labels table and instead use string matching against the labels column), but we could fold them together and just split out that section.

If we do keep them separate it may make sense to promote ListDeleted to a separate grpc method which would avoid the need for the Deleted flag in EntityListRequest

I did look into adding support for proper json functions into the dialects, but managing the different syntaxes and behaviors across postgres, mysql and sqlite was quite complex and brittle.

@DanCech DanCech requested a review from a team as a code owner March 6, 2024 23:07
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Mar 6, 2024
@DanCech DanCech added add to changelog no-backport Skip backport of PR labels Mar 7, 2024
entityQuery.offset = continueToken.StartOffset
}

if len(r.Labels) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

i'm trying to parse the differences between the two list functions. it looks like this if block is one of them. are the other two major differences the table entity_history and entityQuery.addWhere("action", entity.Entity_DELETED)?

Copy link
Member

@toddtreece toddtreece left a comment

Choose a reason for hiding this comment

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

currently it seems like there's additional duplication, but it's kind of a coin toss to know which approach is the best long term. this can always be refactored if the duplication becomes an issue, but leaving that up to @DanCech's expertise

@DanCech DanCech merged commit 1ffd1cc into main Mar 11, 2024
12 checks passed
@DanCech DanCech deleted the unified-storage-list-deleted branch March 11, 2024 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants