From 9676317758a4e88eef94bbcbad4ee086e6d8ad52 Mon Sep 17 00:00:00 2001 From: Frikky Date: Thu, 4 Sep 2025 13:21:51 +0200 Subject: [PATCH] Fixed the problem with nodes going haywire if they crash --- functions/onprem/worker/worker.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/functions/onprem/worker/worker.go b/functions/onprem/worker/worker.go index 2ecffa73..265173a5 100644 --- a/functions/onprem/worker/worker.go +++ b/functions/onprem/worker/worker.go @@ -3238,23 +3238,24 @@ func deploySwarmService(dockercli *dockerclient.Client, name, image string, depl } // Max scale as well + nodeCount := uint64(1) if inputReplicas > 0 && inputReplicas < 100 { if replicas != uint64(inputReplicas) { log.Printf("[DEBUG] Overwriting replicas to %d/node as inputReplicas is set to %d", inputReplicas, inputReplicas) } replicas = uint64(inputReplicas) + } else { + cnt, err := findActiveSwarmNodes(dockercli) + if err != nil { + log.Printf("[ERROR] Unable to find active swarm nodes: %s", err) + } + + if cnt > 0 { + nodeCount = uint64(cnt) + } } - cnt, err := findActiveSwarmNodes(dockercli) - if err != nil { - log.Printf("[ERROR] Unable to find active swarm nodes: %s", err) - } - - nodeCount := uint64(1) - if cnt > 0 { - nodeCount = uint64(cnt) - } replicatedJobs := uint64(replicas * nodeCount) log.Printf("[DEBUG] Deploying app with name %s with image %s", name, image)