From: Jérôme Benoit Date: Mon, 3 Jul 2023 09:58:33 +0000 (+0200) Subject: fix: only display pool utilization when requirements are met X-Git-Tag: v2.6.7~7^2~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c05f0d5094264db0ff50636e794201e60ba7f448;p=poolifier.git fix: only display pool utilization when requirements are met Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 6b28833d..0069fb7f 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -253,7 +253,10 @@ export abstract class AbstractPool< worker: this.worker, minSize: this.minSize, maxSize: this.maxSize, - utilization: round(this.utilization), + ...(this.workerChoiceStrategyContext.getTaskStatisticsRequirements() + .runTime.aggregate && + this.workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime + .aggregate && { utilization: round(this.utilization) }), workerNodes: this.workerNodes.length, idleWorkerNodes: this.workerNodes.reduce( (accumulator, workerNode) => diff --git a/src/pools/pool.ts b/src/pools/pool.ts index 367b4529..855ce000 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -73,7 +73,7 @@ export interface PoolInfo { minSize: number maxSize: number /** Pool utilization ratio. */ - utilization: number + utilization?: number /** Pool total worker nodes */ workerNodes: number /** Pool idle worker nodes */ diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 023b56b4..adf2765f 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -397,7 +397,6 @@ describe('Abstract pool test suite', () => { worker: WorkerTypes.thread, minSize: numberOfWorkers, maxSize: numberOfWorkers, - utilization: 0, workerNodes: numberOfWorkers, idleWorkerNodes: numberOfWorkers, busyWorkerNodes: 0, @@ -418,7 +417,6 @@ describe('Abstract pool test suite', () => { worker: WorkerTypes.cluster, minSize: numberOfWorkers, maxSize: numberOfWorkers * 2, - utilization: 0, workerNodes: numberOfWorkers, idleWorkerNodes: numberOfWorkers, busyWorkerNodes: 0, @@ -717,7 +715,6 @@ describe('Abstract pool test suite', () => { worker: WorkerTypes.thread, minSize: expect.any(Number), maxSize: expect.any(Number), - utilization: 0, workerNodes: expect.any(Number), idleWorkerNodes: expect.any(Number), busyWorkerNodes: expect.any(Number), @@ -754,7 +751,6 @@ describe('Abstract pool test suite', () => { worker: WorkerTypes.thread, minSize: expect.any(Number), maxSize: expect.any(Number), - utilization: 0, workerNodes: expect.any(Number), idleWorkerNodes: expect.any(Number), busyWorkerNodes: expect.any(Number),