From 153179f2d97a4fc3b9afb31ad8875d416414e484 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 6 Jan 2024 10:08:00 +0100 Subject: [PATCH] fix: fix worker node removal handling in worker choice strategies MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ...nterleaved-weighted-round-robin-worker-choice-strategy.ts | 5 ++++- .../round-robin-worker-choice-strategy.ts | 1 + .../weighted-round-robin-worker-choice-strategy.ts | 1 + .../selection-strategies/worker-choice-strategy-context.ts | 3 --- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 97a3aa04..681870cb 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -133,7 +133,10 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< /** @inheritDoc */ public remove (workerNodeKey: number): boolean { if (this.pool.workerNodes.length === 0) { - this.reset() + this.resetWorkerNodeKeyProperties() + this.workerNodeId = 0 + this.workerNodeVirtualTaskRunTime = 0 + return true } if ( this.workerNodeId === workerNodeKey && diff --git a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts index 53f3ba4f..83126d97 100644 --- a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts @@ -52,6 +52,7 @@ export class RoundRobinWorkerChoiceStrategy< public remove (workerNodeKey: number): boolean { if (this.pool.workerNodes.length === 0) { this.reset() + return true } if ( this.nextWorkerNodeKey === workerNodeKey && diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index 38b6dd75..434b1f86 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -72,6 +72,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< public remove (workerNodeKey: number): boolean { if (this.pool.workerNodes.length === 0) { this.reset() + return true } if (this.nextWorkerNodeKey === workerNodeKey) { this.workerNodeVirtualTaskRunTime = 0 diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index b7e0a4a7..40e2e18f 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -188,9 +188,6 @@ export class WorkerChoiceStrategyContext< let retriesCount = 0 do { workerNodeKey = workerChoiceStrategy.choose() - if (workerNodeKey != null && workerNodeKey < 0) { - workerNodeKey = undefined - } if (workerNodeKey == null && chooseCount > 0) { retriesCount++ } -- 2.34.1