Skip to content

Commit 6b78ca7

Browse files
committed
Do not encrypt deletion marker with CMK key
Signed-off-by: Alan Protasio <alanprot@gmail.com>
1 parent b7a3a5d commit 6b78ca7

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* [CHANGE] Bucket Index: Add `series_max_size` and `chunk_max_size` to bucket index. #5489
2626
* [CHANGE] StoreGateway: Rename `cortex_bucket_store_chunk_pool_returned_bytes_total` and `cortex_bucket_store_chunk_pool_requested_bytes_total` to `cortex_bucket_store_chunk_pool_operation_bytes_total`. #5552
2727
* [CHANGE] Query Frontend/Querier: Make build info API disabled by default and add feature flag `api.build-info-enabled` to enable it. #5533
28+
* [CHANGE] Purger: Do no use S3 tenant kms key when uploading deletion marker. #5575
2829
* [FEATURE] Store Gateway: Add `max_downloaded_bytes_per_request` to limit max bytes to download per store gateway request.
2930
* [FEATURE] Added 2 flags `-alertmanager.alertmanager-client.grpc-max-send-msg-size` and ` -alertmanager.alertmanager-client.grpc-max-recv-msg-size` to configure alert manager grpc client message size limits. #5338
3031
* [FEATURE] Query Frontend: Add `cortex_rejected_queries_total` metric for throttled queries. #5356

pkg/compactor/blocks_cleaner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (c *BlocksCleaner) deleteUserMarkedForDeletion(ctx context.Context, userID
277277
if deletedBlocks > 0 || mark.FinishedTime == 0 {
278278
level.Info(userLogger).Log("msg", "updating finished time in tenant deletion mark")
279279
mark.FinishedTime = time.Now().Unix()
280-
return errors.Wrap(cortex_tsdb.WriteTenantDeletionMark(ctx, c.bucketClient, userID, c.cfgProvider, mark), "failed to update tenant deletion mark")
280+
return errors.Wrap(cortex_tsdb.WriteTenantDeletionMark(ctx, c.bucketClient, userID, mark), "failed to update tenant deletion mark")
281281
}
282282

283283
if time.Since(time.Unix(mark.FinishedTime, 0)) < c.cfg.TenantCleanupDelay {

pkg/compactor/blocks_cleaner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ func testBlocksCleanerWithOptions(t *testing.T, options testBlocksCleanerOptions
142142
createDeletionMark(t, bucketClient, "user-2", block7, now.Add(-deletionDelay).Add(-time.Hour)) // Block reached the deletion threshold.
143143

144144
// Blocks for user-3, marked for deletion.
145-
require.NoError(t, tsdb.WriteTenantDeletionMark(context.Background(), bucketClient, "user-3", nil, tsdb.NewTenantDeletionMark(time.Now())))
145+
require.NoError(t, tsdb.WriteTenantDeletionMark(context.Background(), bucketClient, "user-3", tsdb.NewTenantDeletionMark(time.Now())))
146146
block9 := createTSDBBlock(t, bucketClient, "user-3", 10, 30, nil)
147147
block10 := createTSDBBlock(t, bucketClient, "user-3", 30, 50, nil)
148148

149149
// User-4 with no more blocks, but couple of mark and debug files. Should be fully deleted.
150150
user4Mark := tsdb.NewTenantDeletionMark(time.Now())
151151
user4Mark.FinishedTime = time.Now().Unix() - 60 // Set to check final user cleanup.
152-
require.NoError(t, tsdb.WriteTenantDeletionMark(context.Background(), bucketClient, "user-4", nil, user4Mark))
152+
require.NoError(t, tsdb.WriteTenantDeletionMark(context.Background(), bucketClient, "user-4", user4Mark))
153153
user4DebugMetaFile := path.Join("user-4", block.DebugMetas, "meta.json")
154154
require.NoError(t, bucketClient.Upload(context.Background(), user4DebugMetaFile, strings.NewReader("some random content here")))
155155

pkg/ingester/ingester_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,7 +2731,7 @@ func TestIngester_dontShipBlocksWhenTenantDeletionMarkerIsPresent(t *testing.T)
27312731
numObjects := len(bucket.Objects())
27322732
require.NotZero(t, numObjects)
27332733

2734-
require.NoError(t, cortex_tsdb.WriteTenantDeletionMark(context.Background(), bucket, userID, nil, cortex_tsdb.NewTenantDeletionMark(time.Now())))
2734+
require.NoError(t, cortex_tsdb.WriteTenantDeletionMark(context.Background(), bucket, userID, cortex_tsdb.NewTenantDeletionMark(time.Now())))
27352735
numObjects++ // For deletion marker
27362736

27372737
db := i.getTSDB(userID)
@@ -2763,7 +2763,7 @@ func TestIngester_seriesCountIsCorrectAfterClosingTSDBForDeletedTenant(t *testin
27632763
bucket := objstore.NewInMemBucket()
27642764

27652765
// Write tenant deletion mark.
2766-
require.NoError(t, cortex_tsdb.WriteTenantDeletionMark(context.Background(), bucket, userID, nil, cortex_tsdb.NewTenantDeletionMark(time.Now())))
2766+
require.NoError(t, cortex_tsdb.WriteTenantDeletionMark(context.Background(), bucket, userID, cortex_tsdb.NewTenantDeletionMark(time.Now())))
27672767

27682768
i.TSDBState.bucket = bucket
27692769
require.NoError(t, services.StartAndAwaitRunning(context.Background(), i))

pkg/purger/tenant_deletion_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (api *TenantDeletionAPI) DeleteTenant(w http.ResponseWriter, r *http.Reques
5252
return
5353
}
5454

55-
err = cortex_tsdb.WriteTenantDeletionMark(r.Context(), api.bucketClient, userID, api.cfgProvider, cortex_tsdb.NewTenantDeletionMark(time.Now()))
55+
err = cortex_tsdb.WriteTenantDeletionMark(r.Context(), api.bucketClient, userID, cortex_tsdb.NewTenantDeletionMark(time.Now()))
5656
if err != nil {
5757
level.Error(api.logger).Log("msg", "failed to write tenant deletion mark", "user", userID, "err", err)
5858

pkg/storage/tsdb/tenant_deletion_mark.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/pkg/errors"
1212
"github.com/thanos-io/objstore"
1313

14-
"github.com/cortexproject/cortex/pkg/storage/bucket"
1514
util_log "github.com/cortexproject/cortex/pkg/util/log"
1615
)
1716

@@ -38,15 +37,15 @@ func TenantDeletionMarkExists(ctx context.Context, bkt objstore.BucketReader, us
3837
}
3938

4039
// Uploads deletion mark to the tenant location in the bucket.
41-
func WriteTenantDeletionMark(ctx context.Context, bkt objstore.Bucket, userID string, cfgProvider bucket.TenantConfigProvider, mark *TenantDeletionMark) error {
42-
bkt = bucket.NewUserBucketClient(userID, bkt, cfgProvider)
40+
func WriteTenantDeletionMark(ctx context.Context, bkt objstore.Bucket, userID string, mark *TenantDeletionMark) error {
41+
markerFile := path.Join(userID, TenantDeletionMarkPath)
4342

4443
data, err := json.Marshal(mark)
4544
if err != nil {
4645
return errors.Wrap(err, "serialize tenant deletion mark")
4746
}
4847

49-
return errors.Wrap(bkt.Upload(ctx, TenantDeletionMarkPath, bytes.NewReader(data)), "upload tenant deletion mark")
48+
return errors.Wrap(bkt.Upload(ctx, markerFile, bytes.NewReader(data)), "upload tenant deletion mark")
5049
}
5150

5251
// Returns tenant deletion mark for given user, if it exists. If it doesn't exist, returns nil mark, and no error.

pkg/storage/tsdb/tenant_deletion_mark_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ func TestTenantDeletionMarkExists(t *testing.T) {
1313
const username = "user"
1414

1515
for name, tc := range map[string]struct {
16-
objects map[string][]byte
17-
exists bool
16+
objects map[string][]byte
17+
exists bool
18+
deletedUsers []string
1819
}{
1920
"empty": {
2021
objects: nil,
@@ -35,6 +36,13 @@ func TestTenantDeletionMarkExists(t *testing.T) {
3536
},
3637
exists: true,
3738
},
39+
"mark exists - upload via WriteTenantDeletionMark": {
40+
objects: map[string][]byte{
41+
"user/01EQK4QKFHVSZYVJ908Y7HH9E0/meta.json": []byte("data"),
42+
},
43+
deletedUsers: []string{"user"},
44+
exists: true,
45+
},
3846
} {
3947
t.Run(name, func(t *testing.T) {
4048
bkt := objstore.NewInMemBucket()
@@ -43,6 +51,10 @@ func TestTenantDeletionMarkExists(t *testing.T) {
4351
require.NoError(t, bkt.Upload(context.Background(), objName, bytes.NewReader(data)))
4452
}
4553

54+
for _, user := range tc.deletedUsers {
55+
require.NoError(t, WriteTenantDeletionMark(context.Background(), bkt, user, &TenantDeletionMark{}))
56+
}
57+
4658
res, err := TenantDeletionMarkExists(context.Background(), bkt, username)
4759
require.NoError(t, err)
4860
require.Equal(t, tc.exists, res)

0 commit comments

Comments
 (0)