Skip to content

Commit 7622457

Browse files
Merge remote-tracking branch 'origin/improvement/CLDSRV-724-backbeat-related-functional-tests' into test/sylvain/sdk-migration
2 parents b453a76 + df480a2 commit 7622457

File tree

70 files changed

+5655
-2860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+5655
-2860
lines changed

.github/docker/docker-compose.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ services:
9696
ceph:
9797
network_mode: "host"
9898
profiles: ['ceph']
99-
image: ghcr.io/scality/cloudserver/ci-ceph
99+
image: ghcr.io/scality/cloudserver/ci-ceph
100+
volumes:
101+
- /tmp/artifacts/${JOB_NAME}/ceph:/artifacts
100102
sproxyd:
101103
network_mode: "host"
102104
profiles: ['sproxyd']

examples/node-md-search.js

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,46 @@
1-
const { S3 } = require('aws-sdk');
1+
const { S3Client, ListObjectsCommand } = require('@aws-sdk/client-s3');
2+
const { NodeHttpHandler } = require('@smithy/node-http-handler');
3+
const http = require('http');
4+
25
const config = {
3-
sslEnabled: false,
46
endpoint: 'http://127.0.0.1:8000',
5-
signatureCache: false,
6-
signatureVersion: 'v4',
77
region: 'us-east-1',
8-
s3ForcePathStyle: true,
9-
accessKeyId: 'accessKey1',
10-
secretAccessKey: 'verySecretKey1',
8+
forcePathStyle: true,
9+
credentials: {
10+
accessKeyId: 'accessKey1',
11+
secretAccessKey: 'verySecretKey1',
12+
},
13+
requestHandler: new NodeHttpHandler({
14+
httpAgent: new http.Agent({ keepAlive: false }),
15+
}),
1116
};
12-
const s3Client = new S3(config);
1317

14-
const encodedSearch =
15-
encodeURIComponent('x-amz-meta-color="blue"');
16-
const req = s3Client.listObjects({ Bucket: 'bucketname' });
18+
const s3Client = new S3Client(config);
19+
20+
const encodedSearch = encodeURIComponent('x-amz-meta-color="blue"');
21+
22+
const command = new ListObjectsCommand({ Bucket: 'bucketname' });
23+
24+
command.middlewareStack.add(
25+
next => async args => {
26+
if (args.request && args.request.path) {
27+
// eslint-disable-next-line no-param-reassign
28+
args.request.path = `${args.request.path}?search=${encodedSearch}`;
29+
}
30+
return next(args);
31+
},
32+
{
33+
step: 'build',
34+
name: 'addSearchParameter',
35+
priority: 'high'
36+
}
37+
);
1738

18-
// the build event
19-
req.on('build', () => {
20-
req.httpRequest.path = `${req.httpRequest.path}?search=${encodedSearch}`;
21-
});
22-
req.on('success', res => {
23-
process.stdout.write(`Result ${res.data}`);
24-
});
25-
req.on('error', err => {
26-
process.stdout.write(`Error ${err}`);
27-
});
28-
req.send();
39+
// Send command and handle response
40+
s3Client.send(command)
41+
.then(data => {
42+
process.stdout.write(`Result ${JSON.stringify(data)}`);
43+
})
44+
.catch(err => {
45+
process.stdout.write(`Error ${err}`);
46+
});

lib/routes/routeBackbeat.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,41 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
712712
return metadata.putObjectMD(bucketName, objectKey, omVal, options, log,
713713
(err, md) => {
714714
if (err) {
715+
// Handle duplicate key error during repair operation
716+
// This can happen due to race conditions when multiple operations
717+
// try to repair the master version simultaneously. Since repair
718+
// is idempotent, if the master version already exists, we can
719+
// treat this as success.
720+
const errorMessage = err.message || err.toString() || '';
721+
const isRepairDuplicateKeyError = options.repairMaster &&
722+
(errorMessage.includes('E11000') ||
723+
errorMessage.includes('duplicate key') ||
724+
errorMessage.includes('repair'));
725+
726+
if (isRepairDuplicateKeyError) {
727+
log.warn('duplicate key error during repair - treating as success', {
728+
error: err,
729+
method: 'putMetadata',
730+
bucketName,
731+
objectKey,
732+
note: 'Repair operation is idempotent, master version already exists',
733+
});
734+
// Treat as success - the repair already completed
735+
// Get the current metadata to return
736+
return metadata.getObjectMD(bucketName, objectKey, {}, log,
737+
(getErr, currentMD) => {
738+
if (getErr) {
739+
log.warn('could not retrieve metadata after repair duplicate key error', {
740+
error: getErr,
741+
method: 'putMetadata',
742+
});
743+
// Still treat as success since repair likely completed
744+
return next(null, md || {});
745+
}
746+
return next(null, currentMD || md || {});
747+
});
748+
}
749+
715750
log.error('error putting object metadata', {
716751
error: err,
717752
method: 'putMetadata',
@@ -1521,7 +1556,7 @@ function routeBackbeatAPIProxy(request, response, requestContexts, log) {
15211556
});
15221557
return responseJSONBody(err, null, response, log);
15231558
}
1524-
// We don't use the authorization results for now
1559+
// We don't use the authorization results for now
15251560
// as the UI uses the external Cloudserver instance
15261561
// as a proxy to access the Backbeat API service.
15271562

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
},
2020
"homepage": "https://github.com/scality/S3#readme",
2121
"dependencies": {
22+
"@aws-sdk/client-iam": "^3.930.0",
2223
"@aws-sdk/client-s3": "^3.908.0",
24+
"@aws-sdk/client-sts": "^3.930.0",
2325
"@aws-sdk/credential-providers": "^3.864.0",
2426
"@aws-sdk/middleware-retry": "^3.374.0",
2527
"@aws-sdk/protocol-http": "^3.374.0",
@@ -28,7 +30,7 @@
2830
"@azure/storage-blob": "^12.28.0",
2931
"@hapi/joi": "^17.1.1",
3032
"@smithy/node-http-handler": "^3.0.0",
31-
"arsenal": "git+https://github.com/scality/Arsenal#8.2.43",
33+
"arsenal": "git+https://github.com/scality/Arsenal#d1de8c4ac819ee7363323fa8ab14fcdba37a5e65",
3234
"async": "2.6.4",
3335
"bucketclient": "scality/bucketclient#8.2.7",
3436
"bufferutil": "^4.0.8",
@@ -69,7 +71,7 @@
6971
"istanbul": "^0.4.5",
7072
"istanbul-api": "^3.0.0",
7173
"lolex": "^6.0.0",
72-
"mocha": "^10.8.2",
74+
"mocha": "^11.7.5",
7375
"mocha-junit-reporter": "^2.2.1",
7476
"mocha-multi-reporters": "^1.5.1",
7577
"node-mocks-http": "^1.16.1",

tests/functional/aws-node-sdk/test/bucket/aclUsingPredefinedGroups.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ withV4(sigCfg => {
8888
try {
8989
assert.notStrictEqual(err, null);
9090
assert.strictEqual(err.$metadata?.httpStatusCode, 403);
91-
assert.strictEqual(err.Code, 'AccessDenied');
91+
assert.strictEqual(err.name, 'AccessDenied');
9292
done();
9393
} catch (assertError) {
9494
done(assertError);

0 commit comments

Comments
 (0)