handle empty queue
All checks were successful
Pipeline was successful

This commit is contained in:
Tobias Trabelsi 2023-11-08 20:42:20 +01:00
parent 089df0ff7f
commit bbaa89d4c2
Signed by: lerentis
GPG Key ID: FF0C2839718CAF2E

View File

@ -86,10 +86,15 @@ func main() {
"Caller": "Main", "Caller": "Main",
}).Fatal(fmt.Sprintf("Error checking woodpecker queue: %s", err.Error())) }).Fatal(fmt.Sprintf("Error checking woodpecker queue: %s", err.Error()))
} }
if runningTasks <= len(ownedNodes) { if runningTasks <= len(ownedNodes) && runningTasks != 0 {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"Caller": "Main", "Caller": "Main",
}).Info("Still found running tasks. No agent to be removed") }).Info("Still found running tasks. No agent to be removed")
} else {
if len(ownedNodes) == 0 {
log.WithFields(log.Fields{
"Caller": "Main",
}).Infof("Nothing running and not owning any nodes. Recheck in %d", cfg.CheckInterval)
} else { } else {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"Caller": "Main", "Caller": "Main",
@ -107,6 +112,7 @@ func main() {
} }
} }
} }
}
time.Sleep(time.Duration(cfg.CheckInterval) * time.Minute) time.Sleep(time.Duration(cfg.CheckInterval) * time.Minute)
} }
} }