-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #1335 Fixes: #1919 Fixes: #1300 * Clean up of meta files are now started only if block which is being uploaded is older than 2 days (only a mitigation). * Blocks without meta.json are handled properly for all compactor phases. * Prepare for future implementation of https://thanos.io/proposals/201901-read-write-operations-bucket.md/ * Added metric for partialUploadAttempt deletions and delayed it. * More tests. Signed-off-by: Bartlomiej Plotka <[email protected]>
- Loading branch information
Showing
12 changed files
with
317 additions
and
498 deletions.
There are no files selected for viewing
This file contains 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 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,52 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"path" | ||
"testing" | ||
"time" | ||
|
||
"github.com/oklog/ulid" | ||
"github.com/thanos-io/thanos/pkg/block" | ||
"github.com/thanos-io/thanos/pkg/objstore/inmem" | ||
"github.com/thanos-io/thanos/pkg/testutil" | ||
) | ||
|
||
func TestBe(t *testing.T) { | ||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
defer cancel() | ||
|
||
bkt := inmem.NewBucket() | ||
|
||
metaFetcher, err := block.NewMetaFetcher(nil, 32, bkt, "", nil) | ||
testutil.Ok(t, err) | ||
|
||
sy, err := NewSyncer(nil, nil, bkt, metaFetcher, 1, false, false) | ||
testutil.Ok(t, err) | ||
|
||
// Generate 1 block which is older than MinimumAgeForRemoval which has chunk data but no meta. Compactor should delete it. | ||
shouldDeleteID, err := ulid.New(uint64(time.Now().Add(-time.Hour).Unix()*1000), nil) | ||
testutil.Ok(t, err) | ||
|
||
var fakeChunk bytes.Buffer | ||
fakeChunk.Write([]byte{0, 1, 2, 3}) | ||
testutil.Ok(t, bkt.Upload(ctx, path.Join(shouldDeleteID.String(), "chunks", "000001"), &fakeChunk)) | ||
|
||
// Generate 1 block which is older than consistencyDelay but younger than MinimumAgeForRemoval, and which has chunk | ||
// data but no meta. Compactor should ignore it. | ||
shouldIgnoreId, err := ulid.New(uint64(time.Now().Unix()*1000), nil) | ||
testutil.Ok(t, err) | ||
|
||
testutil.Ok(t, bkt.Upload(ctx, path.Join(shouldIgnoreId.String(), "chunks", "000001"), &fakeChunk)) | ||
|
||
testutil.Ok(t, sy.SyncMetas(ctx)) | ||
|
||
exists, err := bkt.Exists(ctx, path.Join(shouldDeleteID.String(), "chunks", "000001")) | ||
testutil.Ok(t, err) | ||
testutil.Equals(t, false, exists) | ||
|
||
exists, err = bkt.Exists(ctx, path.Join(shouldIgnoreId.String(), "chunks", "000001")) | ||
testutil.Ok(t, err) | ||
testutil.Equals(t, true, exists) | ||
} |
This file contains 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 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
Oops, something went wrong.