-
Notifications
You must be signed in to change notification settings - Fork 23
Replace backbeat client with cloudserver client and migration aws sdk to v3 #2679
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/9.1
Are you sure you want to change the base?
Changes from 1 commit
f5ef1da
55796b5
5b422fd
c41b7fd
6a5228e
88f3014
a8b0897
9acb968
e056436
af64540
9547f70
2a70c15
135fb3b
4eb69f0
2d1ec8f
6103d28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ const { | |
| } = require('@scality/cloudserverclient'); | ||
|
|
||
| const mapLimitWaitPendingIfError = require('../../../lib/util/mapLimitWaitPendingIfError'); | ||
| const { attachReqUids, TIMEOUT_MS } = require('../../../lib/clients/utils'); | ||
| const { attachReqUids, isRetryableMiddleware, TIMEOUT_MS } = require('../../../lib/clients/utils'); | ||
| const getExtMetrics = require('../utils/getExtMetrics'); | ||
| const BackbeatTask = require('../../../lib/tasks/BackbeatTask'); | ||
| const { getAccountCredentials } = require('../../../lib/credentials/AccountCredentials'); | ||
|
|
@@ -178,6 +178,7 @@ class ReplicateObject extends BackbeatTask { | |
| } | ||
|
|
||
| _getAndPutPart(sourceEntry, destEntry, part, log, cb) { | ||
| console.log('ZZZZZ 8: _getAndPutPart called for part:', part); | ||
| const partLogger = this.logger.newRequestLogger(log.getUids()); | ||
| this.retry({ | ||
| actionDesc: 'stream part data', | ||
|
|
@@ -262,6 +263,7 @@ class ReplicateObject extends BackbeatTask { | |
| } | ||
|
|
||
| _setupRolesOnce(entry, log, cb) { | ||
| console.log('ZZZZZ 3: _setupRolesOnce called, about to call getBucketReplication'); | ||
| log.debug('getting bucket replication', | ||
| { entry: entry.getLogInfo() }); | ||
| const entryRolesString = entry.getReplicationRoles(); | ||
|
|
@@ -287,8 +289,10 @@ class ReplicateObject extends BackbeatTask { | |
| const command = new GetBucketReplicationCommand( | ||
| { Bucket: entry.getBucket() }); | ||
| attachReqUids(command, log); | ||
| console.log('ZZZZZ 4: About to send GetBucketReplicationCommand'); | ||
| return this.S3source.send(command) | ||
| .then(data => { | ||
| console.log('ZZZZZ 5: GetBucketReplicationCommand succeeded'); | ||
| const replicationEnabled = ( | ||
| data.ReplicationConfiguration.Rules.some( | ||
| rule => entry.getObjectKey().startsWith(rule.Prefix) | ||
|
|
@@ -338,6 +342,8 @@ class ReplicateObject extends BackbeatTask { | |
| return cb(null, roles[0], roles[1]); | ||
| }) | ||
| .catch(err => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: using utils.callbackify() instead of promise.then() allows to keep the same exact structure as before... or you can at least put the |
||
| console.log('ZZZZZ 6: GetBucketReplicationCommand FAILED with error:', err); | ||
| console.log('ZZZZZ 6b: Error properties - retryable:', err.retryable, '$retryable:', err.$retryable, 'code:', err.code, 'name:', err.name); | ||
| // eslint-disable-next-line no-param-reassign | ||
| err.origin = 'source'; | ||
| log.error('error getting replication ' + | ||
|
|
@@ -443,6 +449,7 @@ class ReplicateObject extends BackbeatTask { | |
| } | ||
|
|
||
| _getAndPutData(sourceEntry, destEntry, log, cb) { | ||
| console.log('ZZZZZ 7: _getAndPutData called - about to replicate data'); | ||
| log.debug('replicating data', { entry: sourceEntry.getLogInfo() }); | ||
| if (sourceEntry.getLocation().some(part => { | ||
| const partObj = new ObjectMDLocation(part); | ||
|
|
@@ -522,6 +529,7 @@ class ReplicateObject extends BackbeatTask { | |
| } | ||
|
|
||
| _getAndPutPartOnce(sourceEntry, destEntry, part, log, done) { | ||
| console.log('ZZZZZ 9: _getAndPutPartOnce called - about to send GetObjectCommand'); | ||
| const doneOnce = jsutil.once(done); | ||
| const partObj = new ObjectMDLocation(part); | ||
| const partNumber = partObj.getPartNumber(); | ||
|
|
@@ -541,8 +549,10 @@ class ReplicateObject extends BackbeatTask { | |
| attachReqUids(command, log); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replaces with a attribute in command param? |
||
| const readStartTime = Date.now(); | ||
|
|
||
| console.log('ZZZZZ 10: Sending GetObjectCommand to S3source'); | ||
| this.S3source.send(command, { abortSignal: abortController.signal }) | ||
| .then(response => { | ||
| console.log('ZZZZZ 11: GetObjectCommand succeeded, got response'); | ||
| const incomingMsg = response.Body; | ||
| incomingMsg.on('error', err => { | ||
| if (!sourceStreamAborted && !destRequestAborted) { | ||
|
|
@@ -798,6 +808,12 @@ class ReplicateObject extends BackbeatTask { | |
| }, | ||
| maxAttempts: 1, | ||
| }); | ||
|
|
||
| this.S3source.middlewareStack.add(isRetryableMiddleware(), { | ||
| step: 'deserialize', | ||
| priority: 'high', | ||
| }); | ||
|
|
||
| const requestHandler = { | ||
| [this.sourceConfig.transport === 'https' ? 'httpsAgent' : 'httpAgent']: this.sourceHTTPAgent, | ||
| requestTimeout: TIMEOUT_MS, | ||
|
|
@@ -813,6 +829,10 @@ class ReplicateObject extends BackbeatTask { | |
| disableHostPrefix: true, | ||
| signingEscapePath: false, | ||
| }); | ||
| this.backbeatSource.middlewareStack.add(isRetryableMiddleware(), { | ||
| step: 'deserialize', | ||
| priority: 'high', | ||
| }); | ||
| this.backbeatSourceProxy = new BackbeatMetadataProxy( | ||
| `${this.sourceConfig.transport}://` + | ||
| `${sourceS3.host}:${sourceS3.port}`, | ||
|
|
@@ -862,12 +882,18 @@ class ReplicateObject extends BackbeatTask { | |
| maxAttempts: 1, | ||
| requestHandler, | ||
| }); | ||
| this.backbeatDest.middlewareStack.add(isRetryableMiddleware(), { | ||
| step: 'deserialize', | ||
| priority: 'high', | ||
| }); | ||
| } | ||
|
|
||
| processQueueEntry(sourceEntry, kafkaEntry, done) { | ||
| console.log('ZZZZZ 1: ReplicateObject.processQueueEntry called'); | ||
| const log = this.logger.newRequestLogger(); | ||
| const destEntry = sourceEntry.toReplicaEntry(this.site); | ||
|
|
||
| console.log('ZZZZZ 2: sourceEntry info:', sourceEntry.getLogInfo()); | ||
| log.debug('processing entry', | ||
| { entry: sourceEntry.getLogInfo() }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 is needed as a lot of code relies on having the boolean err.retryable set for the retry logic, which is not the case with sdk v3 anymore.
Some of these retry logic is unit tested