-
Notifications
You must be signed in to change notification settings - Fork 20
AWS-SDK Migration #2482
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
base: development/8.4
Are you sure you want to change the base?
AWS-SDK Migration #2482
Conversation
Hello benzekrimaha,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
ad7e01e to
2f3ed00
Compare
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
f8e5940 to
942aa25
Compare
942aa25 to
f9f96ce
Compare
Wait, you say you've got two Jira ticket 514/524, but they both point to this same PR 🤔 |
| }); | ||
| }); | ||
|
|
||
| it('should create a new master encryption key', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a duplicate of the first test "should support default encryption key per account" 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up, still here
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This completes Sylvain's review. I think I covered everything that makes sense given what should probably change, so I'll come back once it's adressed
| listObjects(params, callback) { | ||
| return this.send(new ListObjectsCommand(params)) | ||
| .then(data => callback && callback(null, data)) | ||
| .catch(err => callback && callback(err)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could make sense to switch this file to ts, but the callback should be required?
If no you can do that
| listObjects(params, callback) { | |
| return this.send(new ListObjectsCommand(params)) | |
| .then(data => callback && callback(null, data)) | |
| .catch(err => callback && callback(err)); | |
| } | |
| listObjects(params, callback) { | |
| return this.send(new ListObjectsCommand(params)) | |
| .then(data => callback?.(null, data)) | |
| .catch(err => callback?.(err)); | |
| } |
But better to always call it?
| maxAttempts: 1, | ||
| requestHandler: undefined, // v3 handles agents differently | ||
| // v3 does not use signatureVersion or sslEnabled directly | ||
| // v3 does not use customUserAgent directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe point to where the logic now is? In the sdk, or elsewhere in the code, so we can know where to look later?
lib/network/kmsAWS/Client.ts
Outdated
| const params = { | ||
| KeyId: masterKeyId, | ||
| KeySpec: 'AES_256', | ||
| KeySpec: "AES_256" as const, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| KeySpec: "AES_256" as const, | |
| KeySpec: 'AES_256' as const, |
Or you can also create the variable as a const once and reuse it here
713cfe4 to
8092247
Compare
e36f845 to
e66bc75
Compare
94ac90f to
87adba6
Compare
746d736 to
d1de8c4
Compare
|
About the stream :
|
| logLevel = 'info'; | ||
| retError = errors.LocationNotFound; | ||
| } else { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: incorrect line wrap
| .then(data => { | ||
| const rawBody = data.Body; | ||
| const stream = this._normalizeSdkStream(rawBody); | ||
| if (!stream || typeof stream.on !== 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no reason to check that stream.on is defined : this is the whole purpose of _normalizeSdkStream, and it should return null if it does not know how to create a stream from the input...
| stream.abort = abortRequest; | ||
| stream.destroy = err => abortRequest(err); | ||
| stream.createReadStream = () => stream; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somehow here we are recreating the whole stream : instead of modifying the "normalized" object returned by AWS SDK, should we not just create the appropriate "stream" (as we need for our use-case) which will return AWS' stream in its createReadStream method?
| stream.abort = abortRequest; | |
| stream.destroy = err => abortRequest(err); | |
| stream.createReadStream = () => stream; | |
| const stream = { | |
| abort: abortRequest, | |
| destroy: abortRequest, | |
| createReadStream: () => data.Body, | |
| }; |
| rawBody.destroy?.(err); | ||
| } | ||
| try { | ||
| originalDestroy(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should destroy be called on abort()? should it not instead be called only on destroy() ?
(not sure what the semantics of JS streams actually are)
| }); | ||
| } | ||
|
|
||
| listObjects(params, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need these extra methods?
the required methods should be already implemented in AwsClient...
| }, 1000), | ||
| isclosed: true, | ||
| }, undefined, logger.newRequestLogger()); | ||
| } catch (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error should be handled through some callback : if we catch an exception here, we may have the bug in production code as well....
--> find where the exception is generated
--> handle it properly, sending the response through appropriate callback (or tweak tests/mocks to properly receive it, and fail the test with done(err) accordingly)
--> remove the try/catch and useless once
| this.putObjectAsync = promisify(this.putObject.bind(this)); | ||
| this.copyObjectAsync = promisify(this.copyObject.bind(this)); | ||
| this.headObjectAsync = promisify(this.headObject.bind(this)); | ||
| this.putObjectTaggingAsync = promisify(this.putObjectTagging.bind(this)); | ||
| this.deleteObjectTaggingAsync = promisify(this.deleteObjectTagging.bind(this)); | ||
| this.completeMultipartUploadAsync = promisify(this.completeMultipartUpload.bind(this)); | ||
| this.deleteObjectAsync = promisify(this.deleteObject.bind(this)); | ||
| this.createMultipartUploadAsync = promisify(this.createMultipartUpload.bind(this)); | ||
| this.uploadPartAsync = promisify(this.uploadPart.bind(this)); | ||
| this.listPartsAsync = promisify(this.listParts.bind(this)); | ||
| this.abortMultipartUploadAsync = promisify(this.abortMultipartUpload.bind(this)); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU, these methods "emulate" the AWS sdk : since we now use them through send() (in AWSClient, etc...), no point in promisify (esp. since every method was moved, so the whole file is changed) and best to async' every function
| if (metaVersionId) { | ||
| result.MetaVersionId = metaVersionId; | ||
| } | ||
| return callback && callback(null, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback must be set, this is the semantic of this function...
(same later)
| }, | ||
| } | ||
|
|
||
| headBucket(params, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really needed? this is used only in GcpClient.healthcheck
healthcheck(location, callback) {
const checkBucketHealth = (bucket, cb) => {
let bucketResp;
this._client.headBucket({ Bucket: bucket }, err => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check other of these "new" API here, and add them only if really needed
|
|
||
| const { getPutTagsMetadata, attachHeaderCaptureMiddleware } = require('../GcpUtils'); | ||
|
|
||
| function putObject(params, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these functions used? directly in cloudserver?
Issue: ARSN-514
Please note that a ticket has been creaed to add coverage not to make this PR more extended : https://scality.atlassian.net/browse/ARSN-524