satellite/metabase: always include encryption in listed object
We implemented filtering of system metadata to reduce DB load in case user will need only list of objects but we missed that encryption configuration is needed to decrypt object key. This change is always including encryption configuration into list objects results. Change-Id: Iaf7b3d8441480e3ad787f19a28f1b648584d5f7d
This commit is contained in:
parent
5ed3846e16
commit
289ae3325a
@ -262,11 +262,10 @@ func doNextQueryAllVersionsWithoutStatus(ctx context.Context, it *objectsIterato
|
||||
if it.prefixLimit == "" {
|
||||
return it.db.db.QueryContext(ctx, `
|
||||
SELECT
|
||||
object_key, stream_id, version, status,
|
||||
object_key, stream_id, version, encryption, status,
|
||||
created_at, expires_at,
|
||||
segment_count,
|
||||
total_plain_size, total_encrypted_size, fixed_segment_size,
|
||||
encryption,
|
||||
encrypted_metadata_nonce, encrypted_metadata, encrypted_metadata_encrypted_key
|
||||
FROM objects
|
||||
WHERE
|
||||
@ -284,11 +283,10 @@ func doNextQueryAllVersionsWithoutStatus(ctx context.Context, it *objectsIterato
|
||||
// works with CRDB.
|
||||
return it.db.db.QueryContext(ctx, `
|
||||
SELECT
|
||||
object_key, stream_id, version, status,
|
||||
object_key, stream_id, version, encryption, status,
|
||||
created_at, expires_at,
|
||||
segment_count,
|
||||
total_plain_size, total_encrypted_size, fixed_segment_size,
|
||||
encryption,
|
||||
encrypted_metadata_nonce, encrypted_metadata, encrypted_metadata_encrypted_key
|
||||
FROM objects
|
||||
WHERE
|
||||
@ -313,7 +311,8 @@ func doNextQueryAllVersionsWithStatus(ctx context.Context, it *objectsIterator)
|
||||
querySelectFields := `
|
||||
object_key
|
||||
,stream_id
|
||||
,version`
|
||||
,version
|
||||
,encryption`
|
||||
|
||||
if it.includeSystemMetadata {
|
||||
querySelectFields += `
|
||||
@ -323,8 +322,7 @@ func doNextQueryAllVersionsWithStatus(ctx context.Context, it *objectsIterator)
|
||||
,segment_count
|
||||
,total_plain_size
|
||||
,total_encrypted_size
|
||||
,fixed_segment_size
|
||||
,encryption`
|
||||
,fixed_segment_size`
|
||||
}
|
||||
|
||||
if it.includeCustomMetadata {
|
||||
@ -392,11 +390,10 @@ func doNextQueryStreamsByKey(ctx context.Context, it *objectsIterator) (_ tagsql
|
||||
|
||||
return it.db.db.QueryContext(ctx, `
|
||||
SELECT
|
||||
object_key, stream_id, version, status,
|
||||
object_key, stream_id, version, encryption, status,
|
||||
created_at, expires_at,
|
||||
segment_count,
|
||||
total_plain_size, total_encrypted_size, fixed_segment_size,
|
||||
encryption,
|
||||
encrypted_metadata_nonce, encrypted_metadata, encrypted_metadata_encrypted_key
|
||||
FROM objects
|
||||
WHERE
|
||||
@ -421,6 +418,7 @@ func (it *objectsIterator) scanItem(item *ObjectEntry) (err error) {
|
||||
&item.ObjectKey,
|
||||
&item.StreamID,
|
||||
&item.Version,
|
||||
encryptionParameters{&item.Encryption},
|
||||
}
|
||||
|
||||
if it.includeSystemMetadata {
|
||||
@ -432,7 +430,6 @@ func (it *objectsIterator) scanItem(item *ObjectEntry) (err error) {
|
||||
&item.TotalPlainSize,
|
||||
&item.TotalEncryptedSize,
|
||||
&item.FixedSegmentSize,
|
||||
encryptionParameters{&item.Encryption},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/common/uuid"
|
||||
@ -1239,6 +1238,12 @@ func TestIterateObjectsWithStatus(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, entry := range collector {
|
||||
// fields that should always be set
|
||||
require.NotEmpty(t, entry.ObjectKey)
|
||||
require.NotEmpty(t, entry.StreamID)
|
||||
require.NotZero(t, entry.Version)
|
||||
require.False(t, entry.Encryption.IsZero())
|
||||
|
||||
require.True(t, entry.CreatedAt.IsZero())
|
||||
require.Nil(t, entry.ExpiresAt)
|
||||
require.Zero(t, entry.Status)
|
||||
@ -1246,7 +1251,6 @@ func TestIterateObjectsWithStatus(t *testing.T) {
|
||||
require.Zero(t, entry.TotalPlainSize)
|
||||
require.Zero(t, entry.TotalEncryptedSize)
|
||||
require.Zero(t, entry.FixedSegmentSize)
|
||||
require.Equal(t, storj.EncryptionParameters{}, entry.Encryption)
|
||||
|
||||
require.NotNil(t, entry.EncryptedMetadataNonce)
|
||||
require.NotNil(t, entry.EncryptedMetadata)
|
||||
|
Loading…
Reference in New Issue
Block a user