Skip to content

Commit 9d4f902

Browse files
committed
Merge branch 'improvement/CLDSRV-819' into q/9.3
2 parents c022d57 + 21363b6 commit 9d4f902

File tree

206 files changed

+24813
-17950
lines changed

Some content is hidden

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

206 files changed

+24813
-17950
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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@
1919
},
2020
"homepage": "https://github.com/scality/S3#readme",
2121
"dependencies": {
22+
"@aws-sdk/client-iam": "^3.930.0",
23+
"@aws-sdk/client-s3": "^3.908.0",
24+
"@aws-sdk/client-sts": "^3.930.0",
25+
"aws-sdk": "^2.1692.0",
26+
"@aws-sdk/credential-providers": "^3.864.0",
27+
"@aws-sdk/middleware-retry": "^3.374.0",
28+
"@aws-sdk/protocol-http": "^3.374.0",
29+
"@aws-sdk/s3-request-presigner": "^3.901.0",
30+
"@aws-sdk/signature-v4": "^3.374.0",
2231
"@azure/storage-blob": "^12.28.0",
2332
"@hapi/joi": "^17.1.1",
24-
"arsenal": "git+https://github.com/scality/Arsenal#8.2.43",
33+
"@smithy/node-http-handler": "^3.0.0",
34+
"arsenal": "git+https://github.com/scality/Arsenal#8.3.0-preview.1",
2535
"async": "2.6.4",
26-
"aws-sdk": "^2.1692.0",
2736
"bucketclient": "scality/bucketclient#8.2.7",
2837
"bufferutil": "^4.0.8",
2938
"commander": "^12.1.0",
@@ -63,7 +72,7 @@
6372
"istanbul": "^0.4.5",
6473
"istanbul-api": "^3.0.0",
6574
"lolex": "^6.0.0",
66-
"mocha": "^10.8.2",
75+
"mocha": "^11.7.5",
6776
"mocha-junit-reporter": "^2.2.1",
6877
"mocha-multi-reporters": "^1.5.1",
6978
"node-mocks-http": "^1.16.1",

0 commit comments

Comments
 (0)