fix(server): fix redis key when trying to delete blob (#8649)

This commit is contained in:
Tamir Kiviti
2025-04-07 14:18:35 +03:00
committed by GitHub
parent f1329c7ea1
commit 36f8d0fd67
2 changed files with 7 additions and 3 deletions

2
pkg/cache/redis.go vendored
View File

@@ -142,7 +142,7 @@ func (c RedisCache) PutBlob(blobID string, blobInfo types.BlobInfo) error {
func (c RedisCache) DeleteBlobs(blobIDs []string) error {
var errs error
for _, blobID := range blobIDs {
key := fmt.Sprintf("%s::%s::%s", redisPrefix, artifactBucket, blobID)
key := fmt.Sprintf("%s::%s::%s", redisPrefix, blobBucket, blobID)
if err := c.client.Del(context.TODO(), key).Err(); err != nil {
errs = multierror.Append(errs, xerrors.Errorf("unable to delete blob %s: %w", blobID, err))
}

View File

@@ -523,8 +523,6 @@ func TestRedisCache_DeleteBlobs(t *testing.T) {
require.NoError(t, err)
defer s.Close()
s.Set(correctHash, "any string")
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
addr := s.Addr()
@@ -535,12 +533,18 @@ func TestRedisCache_DeleteBlobs(t *testing.T) {
c, err := cache.NewRedisCache(fmt.Sprintf("redis://%s", addr), "", "", "", false, 0)
require.NoError(t, err)
s.Set(tt.wantKey, "any string")
err = c.DeleteBlobs(tt.args.blobIDs)
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)
return
}
require.NoError(t, err)
// Verify that the blobs are deleted
got := s.Keys()
assert.NotContains(t, got, tt.wantKey)
})
}
}