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.
This commit is contained in:
1 parent
9299172dd1
commit
caa6c4eda2
1 file changed
+9
-4
@@ -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)
|
||||
}
|
||||
|
||||
if res.ChecksumSHA256 == "" {
|
||||
return nil, status.Error(codes.Internal, "missing checksum response from minio")
|
||||
resChecksum := res.ChecksumSHA256
|
||||
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")
|
||||
}
|
||||
decodedChecksum, err := base64.StdEncoding.DecodeString(res.ChecksumSHA256)
|
||||
decodedChecksum, err := base64.StdEncoding.DecodeString(resChecksum)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to decode checksum value from minio: %v", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user