fix: fix worker node removal handling in worker choice strategies
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 6 Jan 2024 09:08:00 +0000 (10:08 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 6 Jan 2024 09:08:00 +0000 (10:08 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/worker-choice-strategy-context.ts

index 97a3aa04e5b941a31a053c53bf3f4416d15855f0..681870cbf1ad18b9fb10dfb539769c3abdd50777 100644 (file)
@@ -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 &&
index 53f3ba4fd36c0ee70f0918889e5a5edd9708645b..83126d97847887d9a079cc6f875077b1494729c9 100644 (file)
@@ -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 &&
index 38b6dd7509a0c292a4ab1cb82efdad6109d68b1f..434b1f86f0ff6f1f8ace1ce722a2ee983bd4f6b3 100644 (file)
@@ -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
index b7e0a4a7d8d80bc98d55a859cc241f1600bfd41f..40e2e18f303122685c70eb09e824175ab5309cef 100644 (file)
@@ -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++
       }