Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get/Set Object lock config APIs #919

Merged
merged 4 commits into from
Apr 22, 2021

Conversation

prakashsvmx
Copy link
Member

@prakashsvmx prakashsvmx commented Apr 7, 2021

Get/Set Object locking

  • makeBucket(bucketName, region[, makeOpts , callback])

  • setObjectLockConfig(bucketName, lockConfig [, callback])

  • getObjectLockConfig(bucketName [, callback])

@prakashsvmx prakashsvmx self-assigned this Apr 7, 2021
@prakashsvmx prakashsvmx changed the title Get/Set Object locking Get/Set Object lock config APIs Apr 8, 2021
@prakashsvmx prakashsvmx marked this pull request as ready for review April 8, 2021 09:33
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
examples/get-object-lock-config.js Outdated Show resolved Hide resolved
examples/set-object-lock-config.js Show resolved Hide resolved
@kannappanr
Copy link
Contributor

S3Error: Missing required header for this request: Content-MD5
    at Object.parseError (/home/kannappan/work/github.com/minio/minio-js/dist/main/xml-parsers.js:83:11)
    at /home/kannappan/work/github.com/minio/minio-js/dist/main/transformers.js:158:22
    at DestroyableTransform._flush (/home/kannappan/work/github.com/minio/minio-js/dist/main/transformers.js:82:10)
    at DestroyableTransform.prefinish (/home/kannappan/work/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_transform.js:129:10)
    at DestroyableTransform.emit (events.js:310:20)
    at prefinish (/home/kannappan/work/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:611:14)
    at finishMaybe (/home/kannappan/work/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:620:5)
    at endWritable (/home/kannappan/work/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:643:3)
    at DestroyableTransform.Writable.end (/home/kannappan/work/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:571:22)
    at IncomingMessage.onend (_stream_readable.js:660:10) {
  code: 'InvalidRequest',
  requestid: '0YAJM1FM2QTW719D',
  hostid: '8w89j+mgEKvwn7AIJl2GqCkGFuw+80C8JE5hQ6+bHmHSw34WDJIEjdPrQynIkGHwMPsc4qcA4jw=',
  amzRequestid: null,
  amzId2: null,
  amzBucketRegion: null
}

@kannappanr
Copy link
Contributor

content-md5 needs to be calculated for the body

@prakashsvmx
Copy link
Member Author

@kannappanr @ebozduman Thank you for the review.

@kannappanr I have updated and ran functional tests in standalone, distributed and gateway mode.

Request you to PTAL.

@ebozduman
Copy link
Contributor

There is a failure after fixing the missing md5 information in the request.
Here is my script:

var Minio = require('./dist/main/minio')
var s3Client = new Minio.Client({
  endPoint: 's3.amazonaws.com',
  // port: 9001,
  useSSL: true,
  region: 'us-east-1',
  accessKey: 'xxxxxxxxx',
  secretKey: 'xxxxxxxxxxxxxxxxx',
})
bucket = "retlock"
//Set Object lock on a bucket
s3Client.setObjectLockConfig(bucket, {mode:"COMPLIANCE",unit:'Days', validity:10}, function (err){
  if (err) {
    return console.log(err)
  }
  console.log("Success")
})

$ node run-set-object-lock-config.js
S3Error: The XML you provided was not well-formed or did not validate against our published schema
    at Object.parseError (/home/ersan/work/src/github.com/minio/minio-js/dist/main/xml-parsers.js:83:11)
    at /home/ersan/work/src/github.com/minio/minio-js/dist/main/transformers.js:158:22
    at DestroyableTransform._flush (/home/ersan/work/src/github.com/minio/minio-js/dist/main/transformers.js:82:10)
    at DestroyableTransform.prefinish (/home/ersan/work/src/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_transform.js:138:10)
    at DestroyableTransform.emit (events.js:315:20)
    at prefinish (/home/ersan/work/src/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:619:14)
    at finishMaybe (/home/ersan/work/src/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:627:5)
    at endWritable (/home/ersan/work/src/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    at DestroyableTransform.Writable.end (/home/ersan/work/src/github.com/minio/minio-js/node_modules/readable-stream/lib/_stream_writable.js:594:41)
    at IncomingMessage.onend (_stream_readable.js:678:10) {
  code: 'MalformedXML',
  requestid: 'ZAMYAZKN34YER6FY',
  hostid: 'ZtH13VM6AzpL2oLHOKKaS0ZD2XL5ETbI8xtF/zsLH30I2NbRk1MCI6oJHoUiEEbBKGGTyayTNVM=',
  amzRequestid: null,
  amzId2: null,
  amzBucketRegion: null
}

@prakashsvmx
Copy link
Member Author

prakashsvmx commented Apr 13, 2021

@ebozduman @kannappanr Thank you. The issue was an extra key Unit was passed which the minio server ignored but it failed in S3.
I have removed the same and tested against s3. It works fine now.

Copy link
Contributor

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@kannappanr kannappanr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kannappanr kannappanr merged commit 5fa1071 into minio:master Apr 22, 2021
@prakashsvmx prakashsvmx deleted the object-lock-apis branch February 10, 2022 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants