Skip to content

Commit d2774a2

Browse files
committed
feature: BB-80 switch to patch locations from Arsenal
1 parent 7333070 commit d2774a2

File tree

3 files changed

+404
-159
lines changed

3 files changed

+404
-159
lines changed

lib/management/patchConfiguration.js

Lines changed: 1 addition & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const async = require('async');
44
const config = require('../Config');
5-
const { decryptSecret } = require('arsenal').pensieve.credentialUtils;
5+
const { patchLocations } = require('arsenal').patches.locationConstraints;
66
const managementDatabaseName = 'PENSIEVE';
77
const tokenConfigurationKey = 'auth/zenko/remote-management-token';
88
const refreshInterval = 5000;
@@ -22,155 +22,6 @@ function updateIngestionBuckets(locations, metadata, logger, cb) {
2222
});
2323
}
2424

25-
// Move to Arsenal: ARSN-34
26-
function patchLocations(overlayLocations, creds, log) {
27-
if (!overlayLocations) {
28-
return {};
29-
}
30-
31-
const locations = {};
32-
Object.keys(overlayLocations).forEach(k => {
33-
const l = overlayLocations[k];
34-
const location = {
35-
name: k,
36-
objectId: l.objectId,
37-
details: l.details || {},
38-
locationType: l.locationType,
39-
};
40-
let supportsVersioning = false;
41-
let pathStyle = process.env.CI_CEPH !== undefined;
42-
43-
switch (l.locationType) {
44-
case 'location-mem-v1':
45-
location.type = 'mem';
46-
location.details = { supportsVersioning: true };
47-
break;
48-
case 'location-file-v1':
49-
location.type = 'file';
50-
location.details = { supportsVersioning: true };
51-
break;
52-
case 'location-azure-v1':
53-
location.type = 'azure';
54-
if (l.details.secretKey && l.details.secretKey.length > 0) {
55-
location.details = {
56-
bucketMatch: l.details.bucketMatch,
57-
azureStorageEndpoint: l.details.endpoint,
58-
azureStorageAccountName: l.details.accessKey,
59-
azureStorageAccessKey: decryptSecret(creds,
60-
l.details.secretKey),
61-
azureContainerName: l.details.bucketName,
62-
};
63-
}
64-
break;
65-
case 'location-ceph-radosgw-s3-v1':
66-
case 'location-scality-ring-s3-v1':
67-
pathStyle = true; // fallthrough
68-
case 'location-aws-s3-v1':
69-
case 'location-wasabi-v1':
70-
supportsVersioning = true; // fallthrough
71-
case 'location-do-spaces-v1':
72-
location.type = 'aws_s3';
73-
if (l.details.secretKey && l.details.secretKey.length > 0) {
74-
let https = true;
75-
let awsEndpoint = l.details.endpoint ||
76-
's3.amazonaws.com';
77-
if (awsEndpoint.includes('://')) {
78-
const url = new URL(awsEndpoint);
79-
awsEndpoint = url.host;
80-
https = url.protocol.includes('https');
81-
}
82-
83-
location.details = {
84-
credentials: {
85-
accessKey: l.details.accessKey,
86-
secretKey: decryptSecret(creds,
87-
l.details.secretKey),
88-
},
89-
bucketName: l.details.bucketName,
90-
bucketMatch: l.details.bucketMatch,
91-
serverSideEncryption:
92-
Boolean(l.details.serverSideEncryption),
93-
region: l.details.region,
94-
awsEndpoint,
95-
supportsVersioning,
96-
pathStyle,
97-
https,
98-
};
99-
}
100-
break;
101-
case 'location-gcp-v1':
102-
location.type = 'gcp';
103-
if (l.details.secretKey && l.details.secretKey.length > 0) {
104-
location.details = {
105-
credentials: {
106-
accessKey: l.details.accessKey,
107-
secretKey: decryptSecret(creds,
108-
l.details.secretKey),
109-
},
110-
bucketName: l.details.bucketName,
111-
mpuBucketName: l.details.mpuBucketName,
112-
bucketMatch: l.details.bucketMatch,
113-
gcpEndpoint: l.details.endpoint ||
114-
'storage.googleapis.com',
115-
https: true,
116-
};
117-
}
118-
break;
119-
case 'location-scality-sproxyd-v1':
120-
location.type = 'scality';
121-
if (l.details && l.details.bootstrapList &&
122-
l.details.proxyPath) {
123-
location.details = {
124-
supportsVersioning: true,
125-
connector: {
126-
sproxyd: {
127-
chordCos: l.details.chordCos || null,
128-
bootstrap: l.details.bootstrapList,
129-
path: l.details.proxyPath,
130-
},
131-
},
132-
};
133-
}
134-
break;
135-
case 'location-nfs-mount-v1':
136-
location.type = 'pfs';
137-
if (l.details) {
138-
location.details = {
139-
supportsVersioning: true,
140-
bucketMatch: true,
141-
pfsDaemonEndpoint: {
142-
host: `${l.name}-cosmos-pfsd`,
143-
port: 80,
144-
},
145-
};
146-
}
147-
break;
148-
case 'location-scality-hdclient-v2':
149-
location.type = 'scality';
150-
if (l.details && l.details.bootstrapList) {
151-
location.details = {
152-
supportsVersioning: true,
153-
connector: {
154-
hdclient: {
155-
bootstrap: l.details.bootstrapList,
156-
},
157-
},
158-
};
159-
}
160-
break;
161-
default:
162-
log.info('unknown location type', { locationType:
163-
l.locationType });
164-
return;
165-
}
166-
location.sizeLimitGB = l.sizeLimitGB || null;
167-
location.isTransient = Boolean(l.isTransient);
168-
location.legacyAwsBehavior = Boolean(l.legacyAwsBehavior);
169-
locations[location.name] = location;
170-
});
171-
return locations;
172-
}
173-
17425
function updateLocations(locations) {
17526
const locationsWithReplicationBackend = Object.keys(locations)
17627
// NOTE: In Orbit, we don't need to have Scality location in our

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"dependencies": {
4343
"@hapi/joi": "^15.1.0",
4444
"JSONStream": "^1.3.5",
45-
"arsenal": "scality/Arsenal#8.1.3",
45+
"arsenal": "scality/Arsenal#8.1.10",
4646
"async": "^2.3.0",
4747
"aws-sdk": "^2.938.0",
4848
"backo": "^1.1.0",

0 commit comments

Comments
 (0)