Skip to content

Fix delete implementation for s3/gcs/azure backends to account for prefix - #6011

Merged
joe-elliott merged 5 commits into
grafana:mainfrom
kaustubhkurve:fix/backend-delete-api-with-prefix
Dec 5, 2025
Merged

Fix delete implementation for s3/gcs/azure backends to account for prefix#6011
joe-elliott merged 5 commits into
grafana:mainfrom
kaustubhkurve:fix/backend-delete-api-with-prefix

Conversation

@kaustubhkurve

@kaustubhkurve kaustubhkurve commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

What this PR does:
The PR updates the delete implementation for s3/gcs/azure backends to account for prefix if it is configured for the storage backend.

This fixes the issue where tenant indexes are never deleted if a prefix is used. When the poller attempts to write the tenant index for tenants with empty blocklist, the backend writer is unable to delete the index because of the missing prefix in index filepath.

Which issue(s) this PR fixes:
Fixes #5993

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
@CLAassistant

CLAassistant commented Nov 28, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@joe-elliott

Copy link
Copy Markdown
Collaborator

Thanks for the fix! It seems like this test is failing:

https://github.com/grafana/tempo/blob/main/integration/poller/poller_test.go#L214

Can you review?

The backend delete function (which prepends the prefix) is being used
in two places: first to delete indexes directly using the file path,
and secondly, the results from the Find function are iterated over to
delete the files for a tenant. If the result set from the Find
function returns the full path (including the prefix), the delete
function would prepend the prefix again and hence would not target the
correct path. Hence all Find implementations are updated to return
unprefixed key in the result set (we trim the prefix from key before passing
over to the FindFunc arg). This is consistent with the List implementation.
@kaustubhkurve

Copy link
Copy Markdown
Contributor Author

Thanks @joe-elliott, I have pushed a fix for the test failure.

It seems the test was failing due to the presence of prefix in the readWriter.Find function result set.

The delete function is being called from two places: backend.writer.WriteTenantIndex and poller.deleteTenant. The first call passes a non prefixed path for deletion, while the second one passes the full path including the prefix.

In the deleteTenant function, the result of readWriter.Find call is used to generate a list of files to be deleted for a tenant. The Find function was populating the prefixed key in backend.FindMatch (full path to the object including the prefix), and the key from this result was being passed to the Delete function which would again prepend the prefix, causing the test to fail.

I have changed the readWriter.Find implementation for s3/gcs/azure backends to populate non prefixed key in the FindMatch resultset. This is in accordance with the List implementation for these backends, where the prefix is trimmed from the result.

Comment thread tempodb/backend/s3/s3.go Outdated

@joe-elliott joe-elliott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice find and fix! Thank you for the contribution.

@joe-elliott
joe-elliott merged commit f68a697 into grafana:main Dec 5, 2025
36 of 37 checks passed
@MikaelElkiaer

Copy link
Copy Markdown

Has this not been part of a release yet?

mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
…efix (grafana#6011)

* Fix delete impl for s3/gcs/azure backends to account for prefix

* Update changelog

* Omit prefix from backend.readerWriter.Find result set

The backend delete function (which prepends the prefix) is being used
in two places: first to delete indexes directly using the file path,
and secondly, the results from the Find function are iterated over to
delete the files for a tenant. If the result set from the Find
function returns the full path (including the prefix), the delete
function would prepend the prefix again and hence would not target the
correct path. Hence all Find implementations are updated to return
unprefixed key in the result set (we trim the prefix from key before passing
over to the FindFunc arg). This is consistent with the List implementation.

* Add prefix for keypath for versioned deletes

* Remove bucket prefix in backend.Find instead of entire prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants