Skip to content

Commit

Permalink
fix store: handle invalid cache block dir (thanos-io#1505)
Browse files Browse the repository at this point in the history
* fix store: handle invalid cache block dir

Signed-off-by: Martin Chodur <m.chodur@seznam.cz>

* CR: simplify empty store cache block validation logic

Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
  • Loading branch information
FUSAKLA authored and wbh1 committed Sep 17, 2019
1 parent 6ff2115 commit ce0c1b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ We use *breaking* word for marking changes that are not backward compatible (rel

## Unreleased

### Fixed

-[1505](https://github.com/thanos-io/thanos/pull/1505) Thanos store now removes invalid local cache blocks.

## v0.7.0 - 2019.09.02

Accepted into CNCF:
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,8 @@ func (b *bucketBlock) indexCacheFilename() string {
}

func loadMeta(ctx context.Context, logger log.Logger, bucket objstore.BucketReader, dir string, id ulid.ULID) (error, *metadata.Meta) {
// If we haven't seen the block before download the meta.json file.
if _, err := os.Stat(dir); os.IsNotExist(err) {
// If we haven't seen the block before or it is missing the meta.json, download it.
if _, err := os.Stat(path.Join(dir, block.MetaFilename)); os.IsNotExist(err) {
if err := os.MkdirAll(dir, 0777); err != nil {
return errors.Wrap(err, "create dir"), nil
}
Expand Down

0 comments on commit ce0c1b6

Please sign in to comment.