[#543] Add md5 sse-c S3Tests compatability #551

Merged
alexvanin merged 1 commit from pogpp/frostfs-s3-gw:bugfix/543_md5_sse into master 2024-11-28 06:06:56 +00:00
Member

Signed-off-by: Pavel Pogodaev p.pogodaev@yadro.com

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
pogpp added 1 commit 2024-11-15 10:21:32 +00:00
[#543] Add md5 sse-c S3Tests compatability
All checks were successful
/ DCO (pull_request) Successful in 1m25s
/ Vulncheck (pull_request) Successful in 1m37s
/ Builds (pull_request) Successful in 1m50s
/ Lint (pull_request) Successful in 2m52s
/ Tests (pull_request) Successful in 1m49s
6cde68914a
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
pogpp requested review from alexvanin 2024-11-15 10:22:55 +00:00
pogpp requested review from dkirillov 2024-11-15 10:22:56 +00:00
pogpp requested review from mbiryukova 2024-11-15 10:22:57 +00:00
pogpp requested review from r.loginov 2024-11-15 10:22:59 +00:00
pogpp requested review from nzinkevich 2024-11-15 10:23:08 +00:00
pogpp force-pushed bugfix/543_md5_sse from 6cde68914a to 061c029e24 2024-11-15 10:23:56 +00:00 Compare
alexvanin approved these changes 2024-11-18 12:44:43 +00:00
Dismissed
@ -229,0 +229,4 @@
rr := wrapReader(p.Reader, 64*1024, func(buf []byte) {
md5Hash.Write(buf)
})
r, encSize, err := encryptionReader(rr, p.Size, p.Info.Encryption.Key())
Owner

We need investigate on wrappers and, at least, remove hardcode for buffer sizes later on. #555

We need investigate on wrappers and, at least, remove hardcode for buffer sizes later on. https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/issues/555
Member

What about adding tests?

What about adding tests?
pogpp was assigned by dkirillov 2024-11-18 14:13:55 +00:00
pogpp force-pushed bugfix/543_md5_sse from 061c029e24 to ae7b1fa478 2024-11-19 10:41:19 +00:00 Compare
pogpp force-pushed bugfix/543_md5_sse from ae7b1fa478 to 5a5d5eee29 2024-11-19 11:18:57 +00:00 Compare
pogpp dismissed alexvanin's review 2024-11-19 11:18:57 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

dkirillov reviewed 2024-11-19 13:00:43 +00:00
@ -385,0 +385,4 @@
result := listVersions(t, hc, bktName)
require.Len(t, result.Version, 1)
require.EqualValues(t, objLen, result.Version[0].Size)
Member

As I understand this test pass even without fix. Please move these 3 line to TestMultipartEncrypted

diff --git a/api/handler/encryption_test.go b/api/handler/encryption_test.go
index 8efdc451..7dd139a9 100644
--- a/api/handler/encryption_test.go
+++ b/api/handler/encryption_test.go
@@ -369,6 +369,10 @@ func TestMultipartEncrypted(t *testing.T) {
 
        part2Range := getEncryptedObjectRange(t, hc, bktName, objName, len(part1), len(part1)+len(part2)-1)
        require.Equal(t, part2[0:], part2Range)
+
+       result := listVersions(t, hc, bktName)
+       require.Len(t, result.Version, 1)
+       require.EqualValues(t, uint64(partSize+5), result.Version[0].Size)
 }

As I understand this test pass even without fix. Please move these 3 line to `TestMultipartEncrypted` ```diff diff --git a/api/handler/encryption_test.go b/api/handler/encryption_test.go index 8efdc451..7dd139a9 100644 --- a/api/handler/encryption_test.go +++ b/api/handler/encryption_test.go @@ -369,6 +369,10 @@ func TestMultipartEncrypted(t *testing.T) { part2Range := getEncryptedObjectRange(t, hc, bktName, objName, len(part1), len(part1)+len(part2)-1) require.Equal(t, part2[0:], part2Range) + + result := listVersions(t, hc, bktName) + require.Len(t, result.Version, 1) + require.EqualValues(t, uint64(partSize+5), result.Version[0].Size) } ```
dkirillov marked this conversation as resolved
pogpp force-pushed bugfix/543_md5_sse from 5a5d5eee29 to 69a77c0194 2024-11-19 13:43:16 +00:00 Compare
dkirillov approved these changes 2024-11-20 06:35:06 +00:00
Dismissed
dkirillov requested changes 2024-11-20 08:10:09 +00:00
Dismissed
dkirillov left a comment
Member

See the following test

diff --git a/api/handler/encryption_test.go b/api/handler/encryption_test.go
index 7dd139a9..94a06dea 100644
--- a/api/handler/encryption_test.go
+++ b/api/handler/encryption_test.go
@@ -46,6 +46,10 @@ func TestSimpleGetEncrypted(t *testing.T) {
 
        response, _ := getEncryptedObject(tc, bktName, objName)
        require.Equal(t, content, string(response))
+
+       result := listVersions(t, tc, bktName)
+       require.Len(t, result.Version, 1)
+       require.Equal(t, uint64(len(content)), result.Version[0].Size)
 }

See the following test ```diff diff --git a/api/handler/encryption_test.go b/api/handler/encryption_test.go index 7dd139a9..94a06dea 100644 --- a/api/handler/encryption_test.go +++ b/api/handler/encryption_test.go @@ -46,6 +46,10 @@ func TestSimpleGetEncrypted(t *testing.T) { response, _ := getEncryptedObject(tc, bktName, objName) require.Equal(t, content, string(response)) + + result := listVersions(t, tc, bktName) + require.Len(t, result.Version, 1) + require.Equal(t, uint64(len(content)), result.Version[0].Size) } ```
pogpp force-pushed bugfix/543_md5_sse from 69a77c0194 to 64cf1449b8 2024-11-20 13:39:17 +00:00 Compare
pogpp force-pushed bugfix/543_md5_sse from 64cf1449b8 to 12a1e0226a 2024-11-20 13:39:53 +00:00 Compare
pogpp force-pushed bugfix/543_md5_sse from 12a1e0226a to dda6a17e8b 2024-11-20 13:41:36 +00:00 Compare
dkirillov approved these changes 2024-11-20 14:52:59 +00:00
Dismissed
dkirillov left a comment
Member

LGTM

LGTM
potyarkin reviewed 2024-11-20 15:00:03 +00:00
@ -250,0 +253,4 @@
match := hex.EncodeToString(hashBytes) == hex.EncodeToString(createdObj.MD5Sum)
if p.Info.Encryption.Enabled() {
match = hex.EncodeToString(hashBytes) == hex.EncodeToString(md5Hash.Sum(nil))
Member

// drive-by comment:

Is there any reason we convert to string here instead of using bytes.Equal?

_// drive-by comment:_ Is there any reason we convert to string here instead of using `bytes.Equal`?
Owner

Seems like no reason at all. Seems like a good suggestion to me. /cc @pogpp

Seems like no reason at all. Seems like a good suggestion to me. /cc @pogpp
mbiryukova reviewed 2024-11-25 16:26:17 +00:00
@ -449,7 +458,6 @@ func (n *Layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar
initMetadata[AttributeHMACKey] = encInfo.HMACKey
initMetadata[AttributeHMACSalt] = encInfo.HMACSalt
initMetadata[AttributeDecryptedSize] = strconv.FormatUint(multipartObjetSize, 10)
multipartObjetSize = encMultipartObjectSize
Member

Seems that encMultipartObjectSize is unused now

Seems that `encMultipartObjectSize` is unused now
alexvanin reviewed 2024-11-26 11:52:53 +00:00
@ -248,3 +246,3 @@
if r, _, err = encryptionReader(p.Reader, size, p.Encryption.Key()); err != nil {
return nil, fmt.Errorf("create encrypter: %w", err)
}
p.Size = &encSize
Owner

@dkirillov Does this change affect s3-tests by any means? Can we safely remove setting p.Size there?

@dkirillov Does this change affect s3-tests by any means? Can we safely remove setting `p.Size` there?
Member

I would say it doesn't affect. But haven't run all s3 tests on this pr

I would say it doesn't affect. But haven't run all s3 tests on this pr
alexvanin marked this conversation as resolved
alexvanin requested changes 2024-11-26 11:54:09 +00:00
Dismissed
alexvanin left a comment
Owner

Please, see comments

Please, see comments
pogpp force-pushed bugfix/543_md5_sse from dda6a17e8b to 8e260e3475 2024-11-27 08:24:34 +00:00 Compare
pogpp dismissed dkirillov's review 2024-11-27 08:24:36 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

pogpp force-pushed bugfix/543_md5_sse from 8e260e3475 to 910331cd42 2024-11-27 08:27:56 +00:00 Compare
alexvanin added this to the v0.31.1 milestone 2024-11-27 08:28:56 +00:00
pogpp force-pushed bugfix/543_md5_sse from 910331cd42 to d6c9ad4312 2024-11-27 12:44:12 +00:00 Compare
alexvanin approved these changes 2024-11-27 13:16:52 +00:00
alexvanin merged commit e71ba5e22a into master 2024-11-28 06:06:56 +00:00
alexvanin deleted branch bugfix/543_md5_sse 2024-11-28 06:07:00 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-s3-gw#551
No description provided.