Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Clients/CloudserverClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const {
CloudserverClient,
GetMetadataCommand,
PutMetadataCommand,
GetLocationsStatusCommand,
ListFailedCommand,
RetryFailedObjectsCommand,
} = require('@scality/cloudserverclient');
const { http: httpArsn } = require('httpagent');
const https = require('https');
Expand Down Expand Up @@ -63,6 +66,27 @@ class Client {
.then(data => callback(null, data))
.catch(err => callback(err));
}

getLocationsStatus(callback) {
const command = new GetLocationsStatusCommand({});
this.client.send(command)
.then(data => callback(null, data))
.catch(err => callback(err));
}

listFailed(params, callback) {
const command = new ListFailedCommand(params);
this.client.send(command)
.then(data => callback(null, data))
.catch(err => callback(err));
}

retryFailedObjects(params, callback) {
const command = new RetryFailedObjectsCommand();
this.client.send(command)
.then(data => callback(null, data))
.catch(err => callback(err));
}
}

module.exports = Client;
2 changes: 1 addition & 1 deletion StalledRetry/StalledRequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StalledRequestHandler {
}

return this.client.retryFailedObjects({
Body: JSON.stringify(batch.map(entry => entry.toObject())),
Body: Buffer.from(JSON.stringify(batch.map(entry => entry.toObject()))),
}, err => {
if (err) {
return done(err);
Expand Down
31 changes: 13 additions & 18 deletions autoRetryFailedCRR.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { waterfall, mapValuesLimit } = require('async');
const { Logger } = require('werelogs');
const ZenkoClient = require('zenkoclient');
const CloudserverClient = require('./Clients/CloudserverClient');

const log = new Logger('s3utils::autoRetryFailedCRR');
const { ACCESS_KEY } = process.env;
Expand All @@ -16,29 +16,24 @@ if (!SECRET_KEY) {
throw new Error('SECRET_KEY not defined');
}

const zenkoClient = new ZenkoClient({
apiVersion: '2018-07-08-json',
accessKeyId: ACCESS_KEY,
secretAccessKey: SECRET_KEY,
endpoint: ENDPOINT,
s3ForcePathStyle: true,
signatureVersion: 'v4',
maxRetries: 0,
sslEnabled: false,
httpOptions: { timeout: 0 },
});
const cloudserverclient = new CloudserverClient(
ENDPOINT,
ACCESS_KEY,
SECRET_KEY,
);

waterfall([
next => zenkoClient.getLocationsStatus(next),
(locations, next) => {
next => cloudserverclient.getLocationsStatus(next),
(res, next) => {
const locations = res.status || {};
mapValuesLimit(locations, 3, (status, location, done) => {
zenkoClient.listFailed({ Sitename: location }, (err, res) => {
cloudserverclient.listFailed({ Sitename: location }, (err, res) => {
if (err) {
return done(err);
}
if (res.Versions.length > 0) {
return zenkoClient.retryFailedObjects({
Body: JSON.stringify(res.Versions),
if (res.Versions && res.Versions.length > 0) {
return cloudserverclient.retryFailedObjects({
Body: Buffer.from(JSON.stringify(res.Versions)),
}, done);
}
return done();
Expand Down
1 change: 0 additions & 1 deletion cleanupNoncurrentVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const { doWhilst, eachSeries, filterLimit } = require('async');

const { Logger } = require('werelogs');

const BackbeatClient = require('./BackbeatClient');
const CloudserverClient = require('./Clients/CloudserverClient');
const parseOlderThan = require('./utils/parseOlderThan');

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.873.0",
"@aws-sdk/node-http-handler": "^3.374.0",
"@scality/cloudserverclient": "git+https://github.com/scality/cloudserverclient#v1.0.0",
"@scality/cloudserverclient": "^1.0.2",
"@senx/warp10": "^2.0.3",
"@smithy/util-retry": "^4.0.7",
"JSONStream": "^1.3.5",
Expand All @@ -46,8 +46,7 @@
"uuid": "^11.0.3",
"vaultclient": "scality/vaultclient#8.5.1",
"werelogs": "scality/werelogs#8.2.1",
"xml2js": "^0.6.2",
"zenkoclient": "scality/zenkoclient#1.2.1"
"xml2js": "^0.6.2"
},
"resolutions": {
"ioctl": "2.0.2",
Expand Down
20 changes: 7 additions & 13 deletions stalled.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const { Logger } = require('werelogs');
const ZenkoClient = require('zenkoclient');
const CloudserverClient = require('./Clients/CloudserverClient');

const {
MongoClientInterfaceStalled,
Expand Down Expand Up @@ -59,20 +59,14 @@ function wrapperFactory(bucketName, cmpDate, cursor, log) {
}

function handlerFactory(log) {
const zenkoClient = new ZenkoClient({
apiVersion: '2018-07-08-json',
accessKeyId: ACCESS_KEY,
secretAccessKey: SECRET_KEY,
endpoint: ENDPOINT,
s3ForcePathStyle: true,
signatureVersion: 'v4',
maxRetries: 0,
sslEnabled: false,
httpOptions: { timeout: 0 },
});
const cloudserverClient = new CloudserverClient(
ENDPOINT,
ACCESS_KEY,
SECRET_KEY,
);

return new StalledRequestHandler(
zenkoClient,
cloudserverClient,
{
dryRun: DRY_RUN,
batchSize: BATCH_SIZE,
Expand Down
15 changes: 5 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1905,9 +1905,10 @@
resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
integrity sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==

"@scality/cloudserverclient@git+https://github.com/scality/cloudserverclient#v1.0.0":
version "1.0.0"
resolved "git+https://github.com/scality/cloudserverclient#5be9d7bb697ac7010ed1a0f862748c0b4840aa71"
"@scality/cloudserverclient@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@scality/cloudserverclient/-/cloudserverclient-1.0.2.tgz#8d30aafc7dde7ad09d4dcac7323eb2161ce98ffe"
integrity sha512-7Q4b9LQxUGB6DqNxZPDT6rxUAhWgJlXVAOy9ZHY7Vu4m2UOfvbaaxBXo7C4T3d2lxwdgOEWbdc+4GZoykqRI9Q==
dependencies:
"@aws-sdk/client-s3" "^3.896.0"
JSONStream "^1.3.5"
Expand Down Expand Up @@ -3537,7 +3538,7 @@ available-typed-arrays@^1.0.7:
dependencies:
possible-typed-array-names "^1.0.0"

aws-sdk@^2.1005.0, aws-sdk@^2.1691.0:
aws-sdk@^2.1691.0:
version "2.1692.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1692.0.tgz#9dac5f7bfcc5ab45825cc8591b12753aa7d2902c"
integrity sha512-x511uiJ/57FIsbgUe5csJ13k3uzu25uWQE+XqfBis/sB0SFoiElJWXRkgEAUh0U6n40eT3ay5Ue4oPkRMu1LYw==
Expand Down Expand Up @@ -8433,9 +8434,3 @@ yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zenkoclient@scality/zenkoclient#1.2.1:
version "1.2.1"
resolved "https://codeload.github.com/scality/zenkoclient/tar.gz/da298747e292eb2d0058d9e070e8fe93dd897bdc"
dependencies:
aws-sdk "^2.1005.0"
Loading