Allow registry exporter to work with gRPC objects #142

Merged
fyrchik merged 1 commit from elebedeva/xk6-frostfs:fix/registry-export-grpc-obj into master 2024-06-04 12:17:23 +00:00
Member

Close #139

Added CID and OID keys export if S3Bucket or S3Key is empty.

Signed-off-by: Ekaterina Lebedeva ekaterina.lebedeva@yadro.com

Close #139 Added `CID` and `OID` keys export if `S3Bucket` or `S3Key` is empty. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva requested review from storage-core-committers 2024-05-31 18:32:16 +00:00
elebedeva requested review from storage-core-developers 2024-05-31 18:32:17 +00:00
fyrchik approved these changes 2024-05-31 18:48:27 +00:00
Dismissed
@ -69,3 +64,1 @@
comma = ""
for bucket := range bucketMap {
if _, err = f.WriteString(fmt.Sprintf(`%s"%s"`, comma, bucket)); err != nil {
if len(bucketMap) > 1 {
Owner

This is wrong: len(bucketMap) can happily be 1 if we have exactly 1 S3 bucket, and in this case we need to print it.

What we might do instead is to have 2 maps (bucketMap and containerMap) and add only nonzero keys to them.

This is wrong: `len(bucketMap)` can happily be 1 if we have exactly 1 S3 bucket, and in this case we need to print it. What we might do instead is to have 2 maps (`bucketMap` and `containerMap`) and add only nonzero keys to them.
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
@ -83,0 +85,4 @@
func writeObjectInfo(comma string, info *ObjectInfo, f *os.File) (err error) {
var res string
if info.S3Bucket != "" || info.S3Key != "" {
res += fmt.Sprintf(`%s{"bucket":"%s","object":"%s"}`, comma, info.S3Bucket, info.S3Key)
Owner

Why is it res += and not res = ?

Why is it `res += ` and not `res = `?
Author
Member

Didn't notice, fixed

Didn't notice, fixed
fyrchik marked this conversation as resolved
fyrchik dismissed fyrchik's review 2024-05-31 18:48:57 +00:00
Reason:

Approved accidentally

elebedeva force-pushed fix/registry-export-grpc-obj from 91aa27972b to ba769db1e3 2024-06-03 20:16:22 +00:00 Compare
elebedeva requested review from storage-core-committers 2024-06-03 20:19:35 +00:00
acid-ant requested changes 2024-06-04 09:09:24 +00:00
@ -62,3 +67,3 @@
}
if _, err = f.WriteString(`],"buckets":[`); err != nil {
if len(bucketMap) > 0 {
Member

Can be shortened to:

if len(bucketMap) > 0 {
  err = writeContainerInfo("buckets", bucketMap, f)
} else {
  err = writeContainerInfo("containers", containerMap, f)
}
return err
Can be shortened to: ``` if len(bucketMap) > 0 { err = writeContainerInfo("buckets", bucketMap, f) } else { err = writeContainerInfo("containers", containerMap, f) } return err ```
Author
Member

fixed

fixed
elebedeva force-pushed fix/registry-export-grpc-obj from ba769db1e3 to 84f698bbdf 2024-06-04 09:15:06 +00:00 Compare
dstepanov-yadro approved these changes 2024-06-04 09:15:55 +00:00
achuprov approved these changes 2024-06-04 09:45:02 +00:00
fyrchik reviewed 2024-06-04 11:05:03 +00:00
@ -65,0 +69,4 @@
if len(bucketMap) > 0 {
err = writeContainerInfo("buckets", bucketMap, f)
} else {
err = writeContainerInfo("containers", containerMap, f)
Owner

This is tricky: each object was either put via gRPC or via S3.
But both can be in the registry at the same time, so we should print both maps, I believe.

This is tricky: each object was either put via gRPC or via S3. But both can be in the registry at the same time, so we should print both maps, I believe.
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
fyrchik reviewed 2024-06-04 11:06:03 +00:00
@ -70,2 +94,2 @@
for bucket := range bucketMap {
if _, err = f.WriteString(fmt.Sprintf(`%s"%s"`, comma, bucket)); err != nil {
comma := ""
for cnr := range cnrMap {
Owner

This change seems unnecessary and pollutes diff (it was bucketMap, we could continue to accept bucketMap).

This change seems unnecessary and pollutes diff (it was `bucketMap`, we could continue to accept `bucketMap`).
fyrchik marked this conversation as resolved
elebedeva force-pushed fix/registry-export-grpc-obj from 84f698bbdf to ebdadf2868 2024-06-04 11:24:24 +00:00 Compare
fyrchik reviewed 2024-06-04 11:33:50 +00:00
@ -63,2 +69,3 @@
if _, err = f.WriteString(`],"buckets":[`); err != nil {
if len(bucketMap) > 0 {
err = errors.Join(err, writeContainerInfo("buckets", bucketMap, f))
Owner

Why do you use errors.Join?
Error on write most likely will result in corrupted file (invalid JSON), we should just return the error.

Why do you use `errors.Join`? Error on write most likely will result in corrupted file (invalid JSON), we should just return the error.
Author
Member

accidentally pushed, will fix

accidentally pushed, will fix
fyrchik marked this conversation as resolved
elebedeva force-pushed fix/registry-export-grpc-obj from ebdadf2868 to 5a547e6d58 2024-06-04 12:03:24 +00:00 Compare
elebedeva force-pushed fix/registry-export-grpc-obj from 5a547e6d58 to 3dd559a7b1 2024-06-04 12:06:16 +00:00 Compare
fyrchik approved these changes 2024-06-04 12:17:02 +00:00
fyrchik merged commit 3dd559a7b1 into master 2024-06-04 12:17:23 +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/xk6-frostfs#142
No description provided.