Skip to content

Commit 0c3763d

Browse files
committed
Merge branch 'bugfix/ZENKO-745-uniqueLocationMetricsRedisKeys' into q/8.0
2 parents 486abd4 + 23c016d commit 0c3763d

8 files changed

Lines changed: 182 additions & 38 deletions

File tree

lib/Config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ function locationConstraintAssert(locationConstraints) {
160160
assert(supportedBackends.indexOf(locationConstraints[l].type) > -1,
161161
'bad config: locationConstraints[region].type must ' +
162162
`be one of ${supportedBackends}`);
163+
assert(typeof locationConstraints[l].objectId === 'string',
164+
'bad config: locationConstraints[region].objectId is ' +
165+
'mandatory and must be a unique string across locations');
166+
assert(Object.keys(locationConstraints)
167+
.filter(loc => (locationConstraints[loc].objectId ===
168+
locationConstraints[l].objectId))
169+
.length === 1,
170+
'bad config: location constraint objectId ' +
171+
`"${locationConstraints[l].objectId}" is not unique across ` +
172+
'configured locations');
163173
assert(typeof locationConstraints[l].legacyAwsBehavior
164174
=== 'boolean',
165175
'bad config: locationConstraints[region]' +

lib/management/configuration.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function patchConfiguration(newConf, log, cb) {
8585
Object.keys(newConf.locations || {}).forEach(k => {
8686
const l = newConf.locations[k];
8787
const location = {
88+
objectId: l.objectId,
8889
details: {},
8990
};
9091
let supportsVersioning = false;

lib/utapi/utilities.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ function pushMetric(action, log, metricObj) {
216216
return utapi.pushMetric(action, log.getSerializedUids(), utapiObj);
217217
}
218218

219+
/**
220+
* internal: get the unique location ID from the location name
221+
*
222+
* @param {string} location - location name
223+
* @return {string} - location unique ID
224+
*/
225+
function _getLocationId(location) {
226+
return _config.locationConstraints[location].objectId;
227+
}
228+
219229
/**
220230
* Call the Utapi Client 'getLocationMetric' method with the
221231
* associated parameters
@@ -225,7 +235,8 @@ function pushMetric(action, log, metricObj) {
225235
* @return {function} - `utapi.getLocationMetric`
226236
*/
227237
function getLocationMetric(location, log, cb) {
228-
return utapi.getLocationMetric(location, log.getSerializedUids(), cb);
238+
const locationId = _getLocationId(location);
239+
return utapi.getLocationMetric(locationId, log.getSerializedUids(), cb);
229240
}
230241

231242
/**
@@ -238,7 +249,8 @@ function getLocationMetric(location, log, cb) {
238249
* @return {function} - `utapi.pushLocationMetric`
239250
*/
240251
function pushLocationMetric(location, byteLength, log, cb) {
241-
return utapi.pushLocationMetric(location, byteLength,
252+
const locationId = _getLocationId(location);
253+
return utapi.pushLocationMetric(locationId, byteLength,
242254
log.getSerializedUids(), cb);
243255
}
244256

locationConfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,97 @@
11
{
22
"us-east-1": {
33
"type": "file",
4+
"objectId": "us-east-1",
45
"legacyAwsBehavior": true,
56
"details": {}
67
},
78
"us-east-2": {
89
"type": "file",
10+
"objectId": "us-east-2",
911
"legacyAwsBehavior": false,
1012
"details": {}
1113
},
1214
"us-west-1": {
1315
"type": "file",
16+
"objectId": "us-west-1",
1417
"legacyAwsBehavior": false,
1518
"details": {}
1619
},
1720
"us-west-2": {
1821
"type": "file",
22+
"objectId": "us-west-2",
1923
"legacyAwsBehavior": false,
2024
"details": {}
2125
},
2226
"ca-central-1": {
2327
"type": "file",
28+
"objectId": "ca-central-1",
2429
"legacyAwsBehavior": false,
2530
"details": {}
2631
},
2732
"cn-north-1": {
2833
"type": "file",
34+
"objectId": "cn-north-1",
2935
"legacyAwsBehavior": false,
3036
"details": {}
3137
},
3238
"ap-south-1": {
3339
"type": "file",
40+
"objectId": "ap-south-1",
3441
"legacyAwsBehavior": false,
3542
"details": {}
3643
},
3744
"ap-northeast-1": {
3845
"type": "file",
46+
"objectId": "ap-northeast-1",
3947
"legacyAwsBehavior": false,
4048
"details": {}
4149
},
4250
"ap-northeast-2": {
4351
"type": "file",
52+
"objectId": "ap-northeast-2",
4453
"legacyAwsBehavior": false,
4554
"details": {}
4655
},
4756
"ap-southeast-1": {
4857
"type": "file",
58+
"objectId": "ap-southeast-1",
4959
"legacyAwsBehavior": false,
5060
"details": {}
5161
},
5262
"ap-southeast-2": {
5363
"type": "file",
64+
"objectId": "ap-southeast-2",
5465
"legacyAwsBehavior": false,
5566
"details": {}
5667
},
5768
"eu-central-1": {
5869
"type": "file",
70+
"objectId": "eu-central-1",
5971
"legacyAwsBehavior": false,
6072
"details": {}
6173
},
6274
"eu-west-1": {
6375
"type": "file",
76+
"objectId": "eu-west-1",
6477
"legacyAwsBehavior": false,
6578
"details": {}
6679
},
6780
"eu-west-2": {
6881
"type": "file",
82+
"objectId": "eu-west-2",
6983
"legacyAwsBehavior": false,
7084
"details": {}
7185
},
7286
"EU": {
7387
"type": "file",
88+
"objectId": "EU",
7489
"legacyAwsBehavior": false,
7590
"details": {}
7691
},
7792
"sa-east-1": {
7893
"type": "file",
94+
"objectId": "sa-east-1",
7995
"legacyAwsBehavior": false,
8096
"details": {}
8197
}

tests/locationConfig/locationConfigLegacy.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,50 @@
22
{
33
"legacy": {
44
"type": "mem",
5+
"objectId": "legacy",
56
"legacyAwsBehavior": false,
67
"details": {}
78
},
89
"us-east-1": {
910
"type": "file",
11+
"objectId": "us-east-1",
1012
"legacyAwsBehavior": true,
1113

1214
"details": {}
1315
},
1416
"us-east-2": {
1517
"type": "file",
18+
"objectId": "us-east-2",
1619
"legacyAwsBehavior": true,
1720
"details": {}
1821
},
1922
"scality-internal-file": {
2023
"type": "file",
24+
"objectId": "scality-internal-file",
2125
"legacyAwsBehavior": false,
2226
"details": {}
2327
},
2428
"dataFile": {
2529
"type": "file",
30+
"objectId": "dataFile",
2631
"legacyAwsBehavior": false,
2732
"details": {}
2833
},
2934
"scality-internal-mem": {
3035
"type": "mem",
36+
"objectId": "scality-internal-mem",
3137
"legacyAwsBehavior": false,
3238
"details": {}
3339
},
3440
"scality-us-west-1": {
3541
"type": "mem",
42+
"objectId": "scality-us-west-1",
3643
"legacyAwsBehavior": false,
3744
"details": {}
3845
},
3946
"awsbackendencryption": {
4047
"type": "aws_s3",
48+
"objectId": "awsbackendencryption",
4149
"legacyAwsBehavior": true,
4250
"details": {
4351
"awsEndpoint": "s3.amazonaws.com",
@@ -49,6 +57,7 @@
4957
},
5058
"awsbackend": {
5159
"type": "aws_s3",
60+
"objectId": "awsbackend",
5261
"legacyAwsBehavior": true,
5362
"details": {
5463
"awsEndpoint": "s3.amazonaws.com",
@@ -59,6 +68,7 @@
5968
},
6069
"awsbackendmismatch": {
6170
"type": "aws_s3",
71+
"objectId": "awsbackendmismatch",
6272
"legacyAwsBehavior": true,
6373
"details": {
6474
"awsEndpoint": "s3.amazonaws.com",
@@ -69,6 +79,7 @@
6979
},
7080
"awsbackendhttp": {
7181
"type": "aws_s3",
82+
"objectId": "awsbackendhttp",
7283
"legacyAwsBehavior": true,
7384
"details": {
7485
"awsEndpoint": "s3.amazonaws.com",
@@ -80,6 +91,7 @@
8091
},
8192
"awsbackend2": {
8293
"type": "aws_s3",
94+
"objectId": "awsbackend2",
8395
"legacyAwsBehavior": true,
8496
"details": {
8597
"awsEndpoint": "s3.amazonaws.com",
@@ -90,6 +102,7 @@
90102
},
91103
"azurebackend": {
92104
"type": "azure",
105+
"objectId": "azurebackend",
93106
"legacyAwsBehavior": true,
94107
"details": {
95108
"azureStorageEndpoint": "https://fakeaccountname.blob.core.fake.net/",
@@ -101,6 +114,7 @@
101114
},
102115
"azurebackend2": {
103116
"type": "azure",
117+
"objectId": "azurebackend2",
104118
"legacyAwsBehavior": true,
105119
"details": {
106120
"azureStorageEndpoint": "https://fakeaccountname2.blob.core.fake.net/",
@@ -112,6 +126,7 @@
112126
},
113127
"azurebackendmismatch": {
114128
"type": "azure",
129+
"objectId": "azurebackendmismatch",
115130
"legacyAwsBehavior": true,
116131
"details": {
117132
"azureStorageEndpoint": "https://fakeaccountname.blob.core.fake.net/",
@@ -123,6 +138,7 @@
123138
},
124139
"gcpbackend": {
125140
"type": "gcp",
141+
"objectId": "gcpbackend",
126142
"legacyAwsBehavior": true,
127143
"details": {
128144
"gcpEndpoint": "storage.googleapis.com",
@@ -134,6 +150,7 @@
134150
},
135151
"withversioning": {
136152
"type": "aws_s3",
153+
"objectId": "withversioning",
137154
"legacyAwsBehavior": true,
138155
"details": {
139156
"awsEndpoint": "s3.amazonaws.com",
@@ -145,6 +162,7 @@
145162
},
146163
"withoutversioning": {
147164
"type": "aws_s3",
165+
"objectId": "withoutversioning",
148166
"legacyAwsBehavior": true,
149167
"details": {
150168
"awsEndpoint": "s3.amazonaws.com",
@@ -156,6 +174,7 @@
156174
},
157175
"transientfile": {
158176
"type": "file",
177+
"objectId": "transientfile",
159178
"legacyAwsBehavior": false,
160179
"details": {},
161180
"isTransient": true

0 commit comments

Comments
 (0)