From 82787ddc2ed001f6c517b39692cb9cab1a4d1500 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 28 Mar 2022 10:39:36 +0800 Subject: [PATCH] #1654 fix bug --- routers/repo/cloudbrain.go | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index ee44df4f9..fb40c8dec 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1065,16 +1065,29 @@ func SyncCloudbrainStatus() { func HandleTaskWithNoDuration(ctx *context.Context) { log.Info("HandleTaskWithNoDuration start") - cloudBrains, err := models.GetStoppedJobWithNoDurationJob() - if err != nil { - log.Error("HandleTaskWithNoTrainJobDuration failed:", err.Error()) - return - } - if len(cloudBrains) == 0 { - log.Info("HandleTaskWithNoTrainJobDuration:no task need handle") - return + count := 0 + for { + cloudBrains, err := models.GetStoppedJobWithNoDurationJob() + if err != nil { + log.Error("HandleTaskWithNoTrainJobDuration failed:", err.Error()) + break + } + if len(cloudBrains) == 0 { + log.Info("HandleTaskWithNoTrainJobDuration:no task need handle") + break + } + handleNoDurationTask(cloudBrains) + count += len(cloudBrains) + if len(cloudBrains) < 100 { + log.Info("HandleTaskWithNoTrainJobDuration:task less than 100") + break + } } + log.Info("HandleTaskWithNoTrainJobDuration:count=%d", count) +} + +func handleNoDurationTask(cloudBrains []*models.Cloudbrain) { for _, task := range cloudBrains { log.Info("Handle job ,%+v", task) if task.Type == models.TypeCloudBrainOne { @@ -1181,8 +1194,6 @@ func HandleTaskWithNoDuration(ctx *context.Context) { log.Error("task.Type(%s) is error:%d", task.JobName, task.Type) } } - - return } func CloudBrainBenchmarkIndex(ctx *context.Context) {