@@ -13,6 +13,8 @@ import (
13
13
"testing"
14
14
"time"
15
15
16
+ "github.com/cortexproject/cortex/pkg/storage/tsdb/bucketindex"
17
+ cortex_testutil "github.com/cortexproject/cortex/pkg/storage/tsdb/testutil"
16
18
"github.com/go-kit/log"
17
19
"github.com/oklog/ulid"
18
20
"github.com/prometheus/client_golang/prometheus"
@@ -40,6 +42,51 @@ import (
40
42
"github.com/cortexproject/cortex/pkg/util/flagext"
41
43
)
42
44
45
+ func TestBucketStores_CustomerKeyError (t * testing.T ) {
46
+ userToMetric := map [string ]string {
47
+ "user-1" : "series_1" ,
48
+ "user-2" : "series_2" ,
49
+ }
50
+
51
+ ctx := context .Background ()
52
+ cfg := prepareStorageConfig (t )
53
+ cfg .BucketStore .BucketIndex .Enabled = true
54
+
55
+ storageDir := t .TempDir ()
56
+
57
+ for userID , metricName := range userToMetric {
58
+ generateStorageBlock (t , storageDir , userID , metricName , 10 , 100 , 15 )
59
+ }
60
+
61
+ bucket , err := filesystem .NewBucketClient (filesystem.Config {Directory : storageDir })
62
+
63
+ mBucket := & cortex_testutil.MockBucketFailure {
64
+ Bucket : bucket ,
65
+ GetFailures : map [string ]error {
66
+ "user-1" : cortex_testutil .ErrKeyAccessDeniedError ,
67
+ },
68
+ }
69
+ require .NoError (t , err )
70
+
71
+ reg := prometheus .NewPedanticRegistry ()
72
+ stores , err := NewBucketStores (cfg , NewNoShardingStrategy (), mBucket , defaultLimitsOverrides (t ), mockLoggingLevel (), log .NewNopLogger (), reg )
73
+ require .NoError (t , err )
74
+
75
+ // Should set the error on user-1
76
+ require .NoError (t , stores .InitialSync (ctx ))
77
+ require .ErrorIs (t , stores .stores ["user-1" ].err , bucketindex .ErrCustomerManagedKeyError )
78
+ require .ErrorIs (t , stores .stores ["user-2" ].err , nil )
79
+ require .NoError (t , stores .SyncBlocks (context .Background ()))
80
+ require .ErrorIs (t , stores .stores ["user-1" ].err , bucketindex .ErrCustomerManagedKeyError )
81
+ require .ErrorIs (t , stores .stores ["user-2" ].err , nil )
82
+
83
+ // Cleaning the error
84
+ mBucket .GetFailures = map [string ]error {}
85
+ require .NoError (t , stores .SyncBlocks (context .Background ()))
86
+ require .ErrorIs (t , stores .stores ["user-1" ].err , nil )
87
+ require .ErrorIs (t , stores .stores ["user-2" ].err , nil )
88
+ }
89
+
43
90
func TestBucketStores_InitialSync (t * testing.T ) {
44
91
t .Parallel ()
45
92
userToMetric := map [string ]string {
0 commit comments