Fix for writes from Apache Spark. (#4074)

- Due to usage of amazon SDK, spark expects md5sum of empty string to be
  returned when it does PUT on a directory.
- The fix returns md5sum of a empty string for the above mentioned case.
- This fixes the issue of Apache Spark not being able to write into Minio.
master
Karthic Rao 8 years ago committed by Harshavardhana
parent a4209c10ea
commit 929a13f33f
  1. 7
      cmd/object-api-common.go
  2. 20
      cmd/server_test.go

@ -34,6 +34,9 @@ const (
// Buckets meta prefix. // Buckets meta prefix.
bucketMetaPrefix = "buckets" bucketMetaPrefix = "buckets"
// Md5Sum of empty string.
emptyStrMd5Sum = "d41d8cd98f00b204e9800998ecf8427e"
) )
// Global object layer mutex, used for safely updating object layer. // Global object layer mutex, used for safely updating object layer.
@ -67,6 +70,10 @@ func dirObjectInfo(bucket, object string, size int64, metadata map[string]string
// return success. // return success.
md5Sum := metadata["md5Sum"] md5Sum := metadata["md5Sum"]
delete(metadata, "md5Sum") delete(metadata, "md5Sum")
if md5Sum == "" {
md5Sum = emptyStrMd5Sum
}
return ObjectInfo{ return ObjectInfo{
Bucket: bucket, Bucket: bucket,
Name: object, Name: object,

@ -1099,6 +1099,26 @@ func (s *TestSuiteCommon) TestPutObject(c *C) {
// asserted the contents of the fetched object with the expected result. // asserted the contents of the fetched object with the expected result.
c.Assert(true, Equals, bytes.Equal(buffer2.Bytes(), []byte("hello world"))) c.Assert(true, Equals, bytes.Equal(buffer2.Bytes(), []byte("hello world")))
// Test the response when object name ends with a slash.
// This is a special case with size as '0' and object ends with
// a slash separator, we treat it like a valid operation and
// return success.
// The response Etag headers should contain Md5Sum of empty string.
objectName = "objectwith/"
// create HTTP request for object upload.
request, err = newTestSignedRequest("PUT", getPutObjectURL(s.endPoint, bucketName, objectName),
0, nil, s.accessKey, s.secretKey, s.signer)
if s.signer == signerV2 {
c.Assert(err, IsNil)
err = signRequestV2(request, s.accessKey, s.secretKey)
}
c.Assert(err, IsNil)
// execute the HTTP request for object upload.
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
// The response Etag header should contain Md5sum of an empty string.
c.Assert(response.Header.Get("Etag"), Equals, "\""+emptyStrMd5Sum+"\"")
} }
// TestListBuckets - Make request for listing of all buckets. // TestListBuckets - Make request for listing of all buckets.

Loading…
Cancel
Save