-
Notifications
You must be signed in to change notification settings - Fork 820
Perform final tenant cleanup after last block is deleted. #3613
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
Merged
pstibrany
merged 9 commits into
cortexproject:master
from
pstibrany:tenant-deletion-blocks-cleanup
Jan 4, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7f22872
Perform final tenant cleanup after last block is deleted.
pstibrany ae7de9c
Make interval before tenant cleanup shorter, for testing.
pstibrany 24d277e
CHANGELOG.md
pstibrany b25c003
Reduce cleanup interval, for testing.
pstibrany 537a918
Add purger to docker-compose.
pstibrany 61a5947
More logging.
pstibrany f6a3d58
Fix tests after changing log message.
pstibrany a29c56a
Address review feedback.
pstibrany 2bcfb66
Fix test. Add comment.
pstibrany File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package bucket | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/go-kit/kit/log" | ||
"github.com/go-kit/kit/log/level" | ||
"github.com/thanos-io/thanos/pkg/objstore" | ||
) | ||
|
||
// DeletePrefix removes all objects with given prefix, recursively. | ||
// It returns number of deleted objects. | ||
// If deletion of any object fails, it returns error and stops. | ||
func DeletePrefix(ctx context.Context, bkt objstore.Bucket, prefix string, logger log.Logger) (int, error) { | ||
result := 0 | ||
err := bkt.Iter(ctx, prefix, func(name string) error { | ||
if strings.HasSuffix(name, objstore.DirDelim) { | ||
deleted, err := DeletePrefix(ctx, bkt, name, logger) | ||
result += deleted | ||
return err | ||
} | ||
|
||
if err := bkt.Delete(ctx, name); err != nil { | ||
return err | ||
} | ||
result++ | ||
level.Debug(logger).Log("msg", "deleted file", "file", name) | ||
return nil | ||
}) | ||
|
||
return result, err | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any chance of multiple callers updating it? I assume if they do they will write similar times and it will be ok?
Uh oh!
There was an error while loading. Please reload this page.
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.
Within one compactor, it is only called once.
Multiple compactors may happen to call this method concurrently (eg. one compactor is doing
compactioncleanup, and another compactor starts and "takes over" the user). In that case, they may overwrite each-others timestamp if they both happen to delete some blocks or read tenant deletion mark with no timestamp. In that case last write will win, which will delay eventual final cleanup of data for tenant.