Skip to content

Commit 73423e7

Browse files
committed
Revert "Disable utapi"
This reverts commit 5343e89. Issue : CLDSRV-610
1 parent f653b92 commit 73423e7

File tree

7 files changed

+32
-63
lines changed

7 files changed

+32
-63
lines changed

lib/Config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ const {
2020
allowedUtapiEventFilterStates,
2121
supportedLifecycleRules,
2222
} = require('../constants');
23-
24-
// TODO CLDSRV-610: re-enable utapi
25-
// const { utapiVersion } = require('utapi');
26-
const utapiVersion = null;
27-
23+
const { utapiVersion } = require('utapi');
2824
const { scaleMsPerDay } = s3middleware.objectUtils;
2925

3026
const constants = require('../constants');

lib/utapi/utapi.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
require('werelogs').stderrUtils.catchAndTimestampStderr();
22
const _config = require('../Config').config;
3-
// TODO CLDSRV-610 re-enable utapi
4-
/* eslint-disable */
5-
// const { utapiVersion, UtapiServer: utapiServer } = require('utapi');
3+
const { utapiVersion, UtapiServer: utapiServer } = require('utapi');
64

75
// start utapi server
8-
// TODO CLDSRV-610 re-enable utapi
9-
if (utapiVersion === 1 && _config.utapi && false) {
6+
if (utapiVersion === 1 && _config.utapi) {
107
const fullConfig = Object.assign({}, _config.utapi,
118
{ redis: _config.redis });
129
if (_config.vaultd) {

lib/utapi/utapiReindex.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
require('werelogs').stderrUtils.catchAndTimestampStderr();
2-
// TODO CLDSRV-610 re-enable utapi
3-
/* eslint-disable */
4-
// const UtapiReindex = require('utapi').UtapiReindex;
2+
const UtapiReindex = require('utapi').UtapiReindex;
53
const { config } = require('../Config');
64

7-
// TODO CLDSRV-610 re-enable utapi
8-
if (false) {
9-
const reindexConfig = config.utapi && config.utapi.reindex;
10-
if (reindexConfig && reindexConfig.password === undefined) {
11-
reindexConfig.password = config.utapi && config.utapi.redis
12-
&& config.utapi.redis.password;
13-
}
14-
const reindex = new UtapiReindex(reindexConfig);
15-
reindex.start();
5+
const reindexConfig = config.utapi && config.utapi.reindex;
6+
if (reindexConfig && reindexConfig.password === undefined) {
7+
reindexConfig.password = config.utapi && config.utapi.redis
8+
&& config.utapi.redis.password;
169
}
10+
const reindex = new UtapiReindex(reindexConfig);
11+
reindex.start();

lib/utapi/utapiReplay.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
require('werelogs').stderrUtils.catchAndTimestampStderr();
2-
// TODO CLDSRV-610 re-enable utapi
3-
/* eslint-disable */
4-
// const UtapiReplay = require('utapi').UtapiReplay;
2+
const UtapiReplay = require('utapi').UtapiReplay;
53
const _config = require('../Config').config;
64

7-
// TODO CLDSRV-610 re-enable utapi
8-
if (false) {
9-
const utapiConfig = _config.utapi &&
10-
Object.assign({}, _config.utapi, { redis: _config.redis });
11-
const replay = new UtapiReplay(utapiConfig); // start utapi server
12-
replay.start();
13-
}
5+
const utapiConfig = _config.utapi &&
6+
Object.assign({}, _config.utapi, { redis: _config.redis });
7+
const replay = new UtapiReplay(utapiConfig); // start utapi server
8+
replay.start();

lib/utapi/utilities.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@ const http = require('http');
22
const https = require('https');
33
const commander = require('commander');
44
const { auth } = require('arsenal');
5-
// TODO CLDSRV-610 re-enable utapi
6-
/* eslint-disable */
7-
// const { UtapiClient, utapiVersion } = require('utapi');
5+
const { UtapiClient, utapiVersion } = require('utapi');
86
const logger = require('../utilities/logger');
97
const _config = require('../Config').config;
108
const { suppressedUtapiEventFields: suppressedEventFields } = require('../../constants');
119
// setup utapi client
1210
let utapiConfig;
1311

14-
// TODO CLDSRV-610 re-enable utapi
15-
// if (utapiVersion === 1 && _config.utapi) {
16-
// if (_config.utapi.redis === undefined) {
17-
// utapiConfig = Object.assign({}, _config.utapi, { redis: _config.redis });
18-
// } else {
19-
// utapiConfig = Object.assign({}, _config.utapi);
20-
// }
21-
// } else if (utapiVersion === 2) {
22-
// utapiConfig = Object.assign({
23-
// tls: _config.https,
24-
// suppressedEventFields,
25-
// }, _config.utapi || {});
26-
// }
12+
if (utapiVersion === 1 && _config.utapi) {
13+
if (_config.utapi.redis === undefined) {
14+
utapiConfig = Object.assign({}, _config.utapi, { redis: _config.redis });
15+
} else {
16+
utapiConfig = Object.assign({}, _config.utapi);
17+
}
18+
} else if (utapiVersion === 2) {
19+
utapiConfig = Object.assign({
20+
tls: _config.https,
21+
suppressedEventFields,
22+
}, _config.utapi || {});
23+
}
2724

28-
// const utapi = new UtapiClient(utapiConfig);
25+
const utapi = new UtapiClient(utapiConfig);
2926

3027
const bucketOwnerMetrics = [
3128
'completeMultipartUpload',
@@ -260,8 +257,6 @@ function listMetrics(metricType) {
260257
* filtered out and not pushed to utapi.
261258
*/
262259
function pushMetric(action, log, metricObj) {
263-
// TODO CLDSRV-610 re-enable utapi
264-
return;
265260
const {
266261
bucket,
267262
keys,
@@ -360,8 +355,6 @@ function pushMetric(action, log, metricObj) {
360355
* @return {string} - location unique ID
361356
*/
362357
function _getLocationId(location) {
363-
// TODO CLDSRV-610 re-enable utapi
364-
return;
365358
return _config.locationConstraints[location].objectId;
366359
}
367360

@@ -374,8 +367,6 @@ function _getLocationId(location) {
374367
* @return {function} - `utapi.getLocationMetric`
375368
*/
376369
function getLocationMetric(location, log, cb) {
377-
// TODO CLDSRV-610 re-enable utapi
378-
return;
379370
const locationId = _getLocationId(location);
380371
return utapi.getLocationMetric(locationId, log.getSerializedUids(), cb);
381372
}
@@ -390,8 +381,6 @@ function getLocationMetric(location, log, cb) {
390381
* @return {function} - `utapi.pushLocationMetric`
391382
*/
392383
function pushLocationMetric(location, byteLength, log, cb) {
393-
// TODO CLDSRV-610 re-enable utapi
394-
return;
395384
const locationId = _getLocationId(location);
396385
return utapi.pushLocationMetric(locationId, byteLength,
397386
log.getSerializedUids(), cb);

tests/unit/Config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ describe('Config', () => {
536536
process.env.S3_CONFIG_FILE = oldConfig;
537537
});
538538

539-
// TODO CLDSRV-610 re-enable utapi
540-
it.skip('should set up utapi local cache', () => {
539+
it('should set up utapi local cache', () => {
541540
const { ConfigObject } = require('../../lib/Config');
542541
const config = new ConfigObject();
543542

@@ -551,8 +550,7 @@ describe('Config', () => {
551550
);
552551
});
553552

554-
// TODO CLDSRV-610 re-enable utapi
555-
it.skip('should set up utapi redis', () => {
553+
it('should set up utapi redis', () => {
556554
const { ConfigObject } = require('../../lib/Config');
557555
const config = new ConfigObject();
558556

tests/utapi/utilities.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,7 @@ const testEvents = [{
480480
},
481481
}];
482482

483-
// TODO CLDSRV-610 re-enable utapi
484-
describe.skip('utapi v2 pushmetrics utility', () => {
483+
describe('utapi v2 pushmetrics utility', () => {
485484
const log = new werelogs.Logger('utapi-utility');
486485
const { UtapiClient, utapiVersion } = require('utapi');
487486
let pushMetric;

0 commit comments

Comments
 (0)