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

Exclude blocks marked for deletion #4970

Merged
merged 7 commits into from Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan
We use *breaking :warning:* to mark changes that are not backward compatible (relates only to v0.y.z releases.)

## Unreleased
- [#4970](https://github.com/thanos-io/thanos/pull/4970) Added a new flag `exclude-delete` to `tools bucket ls`, which excludes blocks marked for deletion.

### Added

Expand Down
13 changes: 11 additions & 2 deletions cmd/thanos/tools_bucket.go
Expand Up @@ -107,7 +107,8 @@ type bucketVerifyConfig struct {
}

type bucketLsConfig struct {
output string
output string
excludeDelete bool
}

type bucketWebConfig struct {
Expand Down Expand Up @@ -168,6 +169,8 @@ func (tbc *bucketVerifyConfig) registerBucketVerifyFlag(cmd extkingpin.FlagClaus
func (tbc *bucketLsConfig) registerBucketLsFlag(cmd extkingpin.FlagClause) *bucketLsConfig {
cmd.Flag("output", "Optional format in which to print each block's information. Options are 'json', 'wide' or a custom template.").
Short('o').Default("").StringVar(&tbc.output)
cmd.Flag("exclude-delete", "Exclude blocks marked for deletion.").
Default("false").BoolVar(&tbc.excludeDelete)
return tbc
}

Expand Down Expand Up @@ -377,7 +380,13 @@ func registerBucketLs(app extkingpin.AppClause, objStoreConfig *extflag.PathOrCo
return err
}

fetcher, err := block.NewMetaFetcher(logger, block.FetcherConcurrency, bkt, "", extprom.WrapRegistererWithPrefix(extpromPrefix, reg), nil, nil)
var filters []block.MetadataFilter

if tbc.excludeDelete {
ignoreDeletionMarkFilter := block.NewIgnoreDeletionMarkFilter(logger, bkt, 0, block.FetcherConcurrency)
filters = append(filters, ignoreDeletionMarkFilter)
}
fetcher, err := block.NewMetaFetcher(logger, block.FetcherConcurrency, bkt, "", extprom.WrapRegistererWithPrefix(extpromPrefix, reg), filters, nil)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions docs/components/tools.md
Expand Up @@ -402,6 +402,7 @@ usage: thanos tools bucket ls [<flags>]
List all blocks in the bucket.

Flags:
--exclude-delete Exclude blocks marked for deletion.
-h, --help Show context-sensitive help (also try --help-long and
--help-man).
--log.format=logfmt Log format to use. Possible options: logfmt or json.
Expand Down