Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libV2/tasks/BaseTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,20 @@ class BaseTask extends Process {
}

get schedule() {
if (this._program.now) {
const opts = this._program.opts();
if (opts.now) {
return Now;
}
if (this._program.schedule) {
return this._program.schedule;
if (opts.schedule) {
return opts.schedule;
}
return this._defaultSchedule;
}

get lag() {
if (this._program.lag !== undefined) {
return this._program.lag;
const opts = this._program.opts();
if (opts.lag !== undefined) {
return opts.lag;
}
return this._defaultLag;
}
Expand Down
6 changes: 3 additions & 3 deletions libV2/tasks/DiskUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ class MonitorDiskUsage extends BaseTask {
}

get isLeader() {
return this._program.leader !== undefined;
return this._program.opts().leader !== undefined;
}

get isManualUnlock() {
return this._program.unlock !== undefined;
return this._program.opts().unlock !== undefined;
}

get isManualLock() {
return this._program.lock !== undefined;
return this._program.opts().lock !== undefined;
}

async _getUsage(path) {
Expand Down
24 changes: 13 additions & 11 deletions libV2/tasks/ManualAdjust.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class ManualAdjust extends BaseTask {
}

async _start() {
const opts = this._program.opts();
this._utapiClient = new UtapiClient({
host: this._program.host,
port: this._program.port,
host: opts.host,
port: opts.port,
disableRetryCache: true,
});
await super._start();
Expand All @@ -42,38 +43,39 @@ class ManualAdjust extends BaseTask {
async _execute() {
const timestamp = Date.now();

const objectDelta = this._program.objects;
const sizeDelta = this._program.storage;
const opts = this._program.opts();
const objectDelta = opts.objects;
const sizeDelta = opts.storage;

if (!this._program.bucket.length && !this._program.account.length && !this._program.user.length) {
if (!opts.bucket.length && !opts.account.length && !opts.user.length) {
throw Error('You must provided at least one of --bucket, --account or --user');
}

logger.info('writing adjustments');
if (this._program.bucket.length) {
if (opts.bucket.length) {
logger.info('adjusting buckets');
await async.eachSeries(
this._program.bucket,
opts.bucket,
async bucket => this._pushAdjustmentMetric({
bucket, objectDelta, sizeDelta, timestamp,
}),
);
}

if (this._program.account.length) {
if (opts.account.length) {
logger.info('adjusting accounts');
await async.eachSeries(
this._program.account,
opts.account,
async account => this._pushAdjustmentMetric({
account, objectDelta, sizeDelta, timestamp,
}),
);
}

if (this._program.user.length) {
if (opts.user.length) {
logger.info('adjusting users');
await async.eachSeries(
this._program.user,
opts.user,
async user => this._pushAdjustmentMetric({
user, objectDelta, sizeDelta, timestamp,
}),
Expand Down
5 changes: 3 additions & 2 deletions libV2/tasks/Reindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ class ReindexTask extends BaseTask {
}

get targetBuckets() {
if (this._program.bucket.length) {
return this._program.bucket.map(name => ({ name }));
const opts = this._program.opts();
if (opts.bucket.length) {
return opts.bucket.map(name => ({ name }));
}
return metadata.listBuckets();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"engines": {
"node": ">=22"
},
"version": "8.2.4",
"version": "8.2.5",
"description": "API for tracking resource utilization and reporting metrics",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/softLimit/testSoftLimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Test MonitorDiskUsage soft limit', function () {
task = new MonitorDiskUsage({ warp10: warp10Clients });
await task.setup();
task._expirationEnabled = true;
task._program.leader = true;
task._program.opts = () => ({ leader: true });
});

afterEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/v2/server/testGetStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Test getStorage handler', function () {
await cacheClient.connect();

ingestTask = new IngestShard({ warp10: [warp10Clients[0]] });
ingestTask._program = { lag: 0 };
ingestTask._program = { opts: () => ({ lag: 0 }) };
await ingestTask._cache.connect();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/v2/task/testCreateCheckpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Test CreateCheckpoint', function () {
warp10 = new Warp10Client({ nodeId: prefix });
checkpointTask = new CreateCheckpoint({ warp10: [warp10], enableMetrics: true });
await checkpointTask.setup();
checkpointTask._program = { lag: 0, nodeId: prefix };
checkpointTask._program = { opts: () => ({ lag: 0, nodeId: prefix }) };
});

afterEach(async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/v2/task/testCreateSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ describe('Test CreateSnapshot', function () {
warp10 = new Warp10Client({ nodeId: prefix });

checkpointTask = new CreateCheckpoint({ warp10: [warp10] });
checkpointTask._program = { lag: 0, nodeId: prefix };
checkpointTask._program = { opts: () => ({ lag: 0, nodeId: prefix }) };

snapshotTask = new CreateSnapshot({ warp10: [warp10], enableMetrics: true });
await snapshotTask.setup();
snapshotTask._program = { lag: 0, nodeId: prefix };
snapshotTask._program = { opts: () => ({ lag: 0, nodeId: prefix }) };

repairTask = new RepairTask({ warp10: [warp10] });
repairTask._program = { lag: 0, nodeId: prefix };
repairTask._program = { opts: () => ({ lag: 0, nodeId: prefix }) };
});

afterEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/v2/task/testIngestShards.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Test IngestShards', function () {
ingestTask = new IngestShard({ warp10: [warp10], enableMetrics: true });
await ingestTask.setup();
ingestTask._cache._cacheBackend._prefix = prefix;
ingestTask._program = { lag: 0 };
ingestTask._program = { opts: () => ({ lag: 0 }) };
await ingestTask._cache.connect();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/v2/task/testReindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Test ReindexTask', function () {
prefix = uuid();
warp10 = new Warp10Client({ nodeId: prefix });
reindexTask = new ReindexTask({ warp10: [warp10] });
reindexTask._program = { bucket: [], nodeId: prefix };
reindexTask._program = { opts: () => ({ bucket: [], nodeId: prefix }) };
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/v2/task/testRepair.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Test Repair', function () {
warp10 = new Warp10Client({ nodeId: prefix });
repairTask = new RepairTask({ warp10: [warp10], enableMetrics: true });
await repairTask.setup();
repairTask._program = { lag: 0, nodeId: prefix };
repairTask._program = { opts: () => ({ lag: 0, nodeId: prefix }) };
});

afterEach(async () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/v2/testClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('Test UtapiClient', function () {
await cacheClient.connect();

ingestTask = new IngestShard({ warp10: [warp10] });
ingestTask._program = { lag: 0 };
ingestTask._program = { opts: () => ({ lag: 0 }) };
await ingestTask._cache.connect();
});

Expand All @@ -245,4 +245,3 @@ describe('Test UtapiClient', function () {
});
});
});

Loading