Compare commits

...
1 Commits
Author SHA1 Message Date
Hugo caa6c4eda2 feat(storage): Make checksum verification optional
Some 3rd party services the MinIO SDK can connect
with do not return a checksum whenever a file is
uploaded. Before this change, this would lead to
an error, rendering it impossible to operate with
those 3rd party services. With this change, we'll
continue to verify checksums if they come through,
however we won't error out if they don't and the
PutObject call is successful.

Note: There are no new tests with this change as
this behaviour is not unit-testeable at the
moment. I suggest we could have end-to-end tests
for this.
2024-06-10 16:19:20 +01:00
+9 -4
View File
@@ -496,13 +496,18 @@ func (sp *StoragePlugin) PutObject(ctx context.Context, req *pb.PutObjectRequest
return nil, status.Errorf(codes.Internal, "failed to put object into minio: %v", err) return nil, status.Errorf(codes.Internal, "failed to put object into minio: %v", err)
} }
if res.ChecksumSHA256 == "" { resChecksum := res.ChecksumSHA256
return nil, status.Error(codes.Internal, "missing checksum response from minio") if resChecksum == "" {
// We were successful in putting the object but we didn't get a file
// SHA256 checksum from the server. Given that the call was successful,
// assume everything went ok and force the checksum to match so we can
// send it correctly back to Boundary.
resChecksum = checksum
} }
if checksum != res.ChecksumSHA256 { if checksum != resChecksum {
return nil, status.Error(codes.Internal, "mismatched checksum") return nil, status.Error(codes.Internal, "mismatched checksum")
} }
decodedChecksum, err := base64.StdEncoding.DecodeString(res.ChecksumSHA256) decodedChecksum, err := base64.StdEncoding.DecodeString(resChecksum)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "failed to decode checksum value from minio: %v", err) return nil, status.Errorf(codes.Internal, "failed to decode checksum value from minio: %v", err)
} }