fix: only display pool utilization when requirements are met
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 3 Jul 2023 09:58:33 +0000 (11:58 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 3 Jul 2023 09:58:33 +0000 (11:58 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts
src/pools/pool.ts
tests/pools/abstract/abstract-pool.test.js

index 6b28833d71ffac9176d60eab835aa5bfaffff41e..0069fb7fadc61c95196982365adfaf60561069fa 100644 (file)
@@ -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) =>
index 367b45291853f0ca87c3b52ddf2621ae3465c3f4..855ce000497aadd1019a052db26707d188b418b1 100644 (file)
@@ -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 */
index 023b56b414c4c3453d269c5f5605d0e69a8c4275..adf2765f7e67bcb68ffb11a534574fa3e18c3907 100644 (file)
@@ -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),