Skip to content

Commit bbc0ff8

Browse files
Remove SupportsEncryption method. (#9390)
Originally encryption required a dedicated customer partition. Then later we added encryption information into the pebble key which allowed us to distinguish encrypted content for different customers.
1 parent 7d1d708 commit bbc0ff8

File tree

14 files changed

+2
-154
lines changed

14 files changed

+2
-154
lines changed

enterprise/server/backends/distributed/distributed.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,3 @@ func (c *Cache) SupportsCompressor(compressor repb.Compressor_Value) bool {
14381438
}
14391439
return false
14401440
}
1441-
1442-
func (c *Cache) SupportsEncryption(ctx context.Context) bool {
1443-
return c.local.SupportsEncryption(ctx)
1444-
}

enterprise/server/backends/gcs_cache/gcs_cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,3 @@ func (g *GCSCache) Stop() error {
526526
func (g *GCSCache) SupportsCompressor(compressor repb.Compressor_Value) bool {
527527
return compressor == repb.Compressor_IDENTITY
528528
}
529-
530-
func (g *GCSCache) SupportsEncryption(ctx context.Context) bool {
531-
return false
532-
}

enterprise/server/backends/memcache/memcache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,3 @@ func (c *Cache) Stop() error {
321321
func (c *Cache) SupportsCompressor(compressor repb.Compressor_Value) bool {
322322
return compressor == repb.Compressor_IDENTITY
323323
}
324-
325-
func (c *Cache) SupportsEncryption(ctx context.Context) bool {
326-
return false
327-
}

enterprise/server/backends/migration_cache/migration_cache.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,6 @@ func pebbleCacheFromConfig(env environment.Env, cfg *PebbleCacheConfig) (*pebble
180180
return c, nil
181181
}
182182

183-
func (mc *MigrationCache) checkSafeToMigrate(ctx context.Context) error {
184-
u, err := mc.env.GetAuthenticator().AuthenticatedUser(ctx)
185-
if err != nil {
186-
// This is an anon user which is ok.
187-
return nil
188-
}
189-
if !u.GetCacheEncryptionEnabled() {
190-
return nil
191-
}
192-
if mc.src.SupportsEncryption(ctx) && !mc.dest.SupportsEncryption(ctx) {
193-
return status.FailedPreconditionError("not safe to copy from encrypted cache to unencrypted cache")
194-
}
195-
return nil
196-
}
197-
198183
func (mc *MigrationCache) doubleRead() bool {
199184
return mc.doubleReadPercentage > 0 && rand.Float64() < mc.doubleReadPercentage
200185
}
@@ -263,9 +248,6 @@ func (mc *MigrationCache) Metadata(ctx context.Context, r *rspb.ResourceName) (*
263248
}
264249

265250
func (mc *MigrationCache) FindMissing(ctx context.Context, resources []*rspb.ResourceName) ([]*repb.Digest, error) {
266-
if err := mc.checkSafeToMigrate(ctx); err != nil {
267-
return nil, err
268-
}
269251
srcMissing, srcErr := mc.src.FindMissing(ctx, resources)
270252

271253
if mc.doubleRead() {
@@ -301,9 +283,6 @@ func (mc *MigrationCache) FindMissing(ctx context.Context, resources []*rspb.Res
301283
}
302284

303285
func (mc *MigrationCache) GetMulti(ctx context.Context, resources []*rspb.ResourceName) (map[*repb.Digest][]byte, error) {
304-
if err := mc.checkSafeToMigrate(ctx); err != nil {
305-
return nil, err
306-
}
307286
srcData, srcErr := mc.src.GetMulti(ctx, resources)
308287

309288
go func() {
@@ -347,10 +326,6 @@ func (mc *MigrationCache) GetMulti(ctx context.Context, resources []*rspb.Resour
347326
}
348327

349328
func (mc *MigrationCache) SetMulti(ctx context.Context, kvs map[*rspb.ResourceName][]byte) error {
350-
if err := mc.checkSafeToMigrate(ctx); err != nil {
351-
return err
352-
}
353-
354329
eg, gctx := errgroup.WithContext(ctx)
355330
var srcErr, dstErr error
356331

@@ -561,10 +536,6 @@ func (d *doubleReader) Close() error {
561536
}
562537

563538
func (mc *MigrationCache) Reader(ctx context.Context, r *rspb.ResourceName, uncompressedOffset, limit int64) (io.ReadCloser, error) {
564-
if err := mc.checkSafeToMigrate(ctx); err != nil {
565-
return nil, err
566-
}
567-
568539
eg := &errgroup.Group{}
569540
var dstErr error
570541
var destReader io.ReadCloser
@@ -772,10 +743,6 @@ func (aw *asyncWriter) Close() error {
772743
}
773744

774745
func (mc *MigrationCache) Writer(ctx context.Context, r *rspb.ResourceName) (interfaces.CommittedWriteCloser, error) {
775-
if err := mc.checkSafeToMigrate(ctx); err != nil {
776-
return nil, err
777-
}
778-
779746
if mc.asyncDestWrites {
780747
// We will write to the destination cache in the background.
781748
mc.sendNonBlockingCopy(ctx, r, false /*=onlyCopyMissing*/)
@@ -800,9 +767,6 @@ func (mc *MigrationCache) Writer(ctx context.Context, r *rspb.ResourceName) (int
800767
}
801768

802769
func (mc *MigrationCache) Get(ctx context.Context, r *rspb.ResourceName) ([]byte, error) {
803-
if err := mc.checkSafeToMigrate(ctx); err != nil {
804-
return nil, err
805-
}
806770
srcBuf, srcErr := mc.src.Get(ctx, r)
807771

808772
go func() {
@@ -1053,7 +1017,3 @@ func (mc *MigrationCache) Stop() error {
10531017
func (mc *MigrationCache) SupportsCompressor(compressor repb.Compressor_Value) bool {
10541018
return mc.src.SupportsCompressor(compressor) && mc.dest.SupportsCompressor(compressor)
10551019
}
1056-
1057-
func (mc *MigrationCache) SupportsEncryption(ctx context.Context) bool {
1058-
return mc.src.SupportsEncryption(ctx) && mc.dest.SupportsEncryption(ctx)
1059-
}

enterprise/server/backends/pebble_cache/pebble_cache.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3461,13 +3461,3 @@ func (p *PebbleCache) Stop() error {
34613461

34623462
return nil
34633463
}
3464-
3465-
func (p *PebbleCache) SupportsEncryption(ctx context.Context) bool {
3466-
_, partID := p.lookupGroupAndPartitionID(ctx, "")
3467-
for _, part := range p.partitions {
3468-
if part.ID == partID {
3469-
return part.EncryptionSupported
3470-
}
3471-
}
3472-
return false
3473-
}

enterprise/server/backends/pebble_cache/pebble_cache_test.go

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,70 +2861,6 @@ func BenchmarkSet(b *testing.B) {
28612861
}
28622862
}
28632863

2864-
func TestSupportsEncryption(t *testing.T) {
2865-
te := testenv.GetTestEnv(t)
2866-
apiKey1 := "AK2222"
2867-
group1 := "GR7890"
2868-
apiKey2 := "AK3333"
2869-
group2 := "GR1111"
2870-
testUsers := testauth.TestUsers(apiKey1, group1, apiKey2, group2)
2871-
te.SetAuthenticator(testauth.NewTestAuthenticator(testUsers))
2872-
2873-
maxSizeBytes := int64(1_000_000_000) // 1GB
2874-
rootDir := testfs.MakeTempDir(t)
2875-
group1PartitionID := "user1part"
2876-
group2PartitionID := "user2part"
2877-
opts := &pebble_cache.Options{
2878-
RootDirectory: rootDir,
2879-
MaxSizeBytes: maxSizeBytes,
2880-
MaxInlineFileSizeBytes: 100,
2881-
Partitions: []disk.Partition{
2882-
{
2883-
ID: pebble_cache.DefaultPartitionID,
2884-
MaxSizeBytes: maxSizeBytes,
2885-
},
2886-
{
2887-
ID: group1PartitionID,
2888-
MaxSizeBytes: maxSizeBytes,
2889-
},
2890-
{
2891-
ID: group2PartitionID,
2892-
MaxSizeBytes: maxSizeBytes,
2893-
EncryptionSupported: true,
2894-
},
2895-
},
2896-
PartitionMappings: []disk.PartitionMapping{
2897-
{
2898-
GroupID: group1,
2899-
PartitionID: group1PartitionID,
2900-
},
2901-
{
2902-
GroupID: group2,
2903-
PartitionID: group2PartitionID,
2904-
},
2905-
},
2906-
}
2907-
2908-
pc, err := pebble_cache.NewPebbleCache(te, opts)
2909-
require.NoError(t, err)
2910-
err = pc.Start()
2911-
require.NoError(t, err)
2912-
2913-
// Anon write should go to the default partition which doesn't support
2914-
// encryption.
2915-
ctx := getAnonContext(t, te)
2916-
require.False(t, pc.SupportsEncryption(ctx))
2917-
2918-
// First group is mapped to a partition that does not have encryption
2919-
// support.
2920-
ctx = te.GetAuthenticator().AuthContextFromAPIKey(context.Background(), apiKey1)
2921-
require.False(t, pc.SupportsEncryption(ctx))
2922-
2923-
// Second user should be able to use encryption.
2924-
ctx = te.GetAuthenticator().AuthContextFromAPIKey(context.Background(), apiKey2)
2925-
require.True(t, pc.SupportsEncryption(ctx))
2926-
}
2927-
29282864
func TestSampling(t *testing.T) {
29292865
activeKeyVersion := int64(4)
29302866

enterprise/server/backends/redis_cache/redis_cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,3 @@ func (c *Cache) Stop() error {
372372
func (c *Cache) SupportsCompressor(compressor repb.Compressor_Value) bool {
373373
return compressor == repb.Compressor_IDENTITY
374374
}
375-
376-
func (c *Cache) SupportsEncryption(ctx context.Context) bool {
377-
return false
378-
}

enterprise/server/backends/s3_cache/s3_cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,3 @@ func (s3c *S3Cache) Stop() error {
616616
func (s3c *S3Cache) SupportsCompressor(compressor repb.Compressor_Value) bool {
617617
return compressor == repb.Compressor_IDENTITY
618618
}
619-
620-
func (s3c *S3Cache) SupportsEncryption(ctx context.Context) bool {
621-
return false
622-
}

enterprise/server/composable_cache/composable_cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,3 @@ func (c *ComposableCache) Writer(ctx context.Context, r *rspb.ResourceName) (int
277277
func (c *ComposableCache) SupportsCompressor(compressor repb.Compressor_Value) bool {
278278
return compressor == repb.Compressor_IDENTITY
279279
}
280-
281-
func (c *ComposableCache) SupportsEncryption(ctx context.Context) bool {
282-
return false
283-
}

enterprise/server/raft/cache/cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,6 @@ func (rc *RaftCache) SupportsCompressor(compressor repb.Compressor_Value) bool {
660660
return compressor == repb.Compressor_IDENTITY
661661
}
662662

663-
func (rc *RaftCache) SupportsEncryption(ctx context.Context) bool {
664-
return false
665-
}
666-
667663
func (rc *RaftCache) olderThanThreshold(t time.Time, threshold time.Duration) bool {
668664
age := rc.clock.Since(t)
669665
return age >= threshold

server/backends/disk_cache/disk_cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,3 @@ func (p *partition) writer(ctx context.Context, r *rspb.ResourceName) (interface
12291229
func (c *DiskCache) SupportsCompressor(compressor repb.Compressor_Value) bool {
12301230
return compressor == repb.Compressor_IDENTITY
12311231
}
1232-
1233-
func (c *DiskCache) SupportsEncryption(ctx context.Context) bool {
1234-
return false
1235-
}

server/backends/memory_cache/memory_cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,3 @@ func (m *MemoryCache) Stop() error {
246246
func (m *MemoryCache) SupportsCompressor(compressor repb.Compressor_Value) bool {
247247
return compressor == repb.Compressor_IDENTITY
248248
}
249-
250-
func (c *MemoryCache) SupportsEncryption(ctx context.Context) bool {
251-
return false
252-
}

server/interfaces/interfaces.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ type Cache interface {
287287

288288
// SupportsCompressor returns whether the cache supports storing data compressed with the given compressor
289289
SupportsCompressor(compressor repb.Compressor_Value) bool
290-
SupportsEncryption(ctx context.Context) bool
291290
}
292291

293292
type StoppableCache interface {

server/util/disk/disk.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ var (
3232
)
3333

3434
type Partition struct {
35-
ID string `yaml:"id" json:"id" usage:"The ID of the partition."`
36-
MaxSizeBytes int64 `yaml:"max_size_bytes" json:"max_size_bytes" usage:"Maximum size of the partition."`
37-
EncryptionSupported bool `yaml:"encryption_supported" json:"encryption_supported" usage:"Whether encrypted data can be stored on this partition."`
35+
ID string `yaml:"id" json:"id" usage:"The ID of the partition."`
36+
MaxSizeBytes int64 `yaml:"max_size_bytes" json:"max_size_bytes" usage:"Maximum size of the partition."`
3837
}
3938

4039
type PartitionMapping struct {

0 commit comments

Comments
 (0)