From 538be9e1aeaed71a5d3c032f65db26f2b640ba2c Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 21 Dec 2021 11:24:27 +0800 Subject: [PATCH] cloudbrain restart --- modules/cloudbrain/cloudbrain.go | 7 +++++++ routers/repo/cloudbrain.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 394afbcfa..c907f8cd9 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -2,6 +2,7 @@ package cloudbrain import ( "code.gitea.io/gitea/modules/storage" + "encoding/json" "errors" "strconv" @@ -108,6 +109,9 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, uuid var resourceSpec *models.ResourceSpec + if ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs) + } for _, spec := range ResourceSpecs.ResourceSpec { if resourceSpecId == spec.Id { resourceSpec = spec @@ -226,6 +230,9 @@ func RestartTask(ctx *context.Context, task *models.Cloudbrain) error { jobName := task.JobName var resourceSpec *models.ResourceSpec + if ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs) + } for _, spec := range ResourceSpecs.ResourceSpec { if task.ResourceSpecId == spec.Id { resourceSpec = spec diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index a5f582ae2..87630bbe0 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -256,7 +256,7 @@ func CloudBrainRestart(ctx *context.Context) { 3、更新此任务的状态 */ - //todo: 是否启用事务? + //todo: 是否启用事务?处理时间太长,容易卡住 var jobID = ctx.Params(":jobid") task, err := models.GetCloudbrainByJobID(jobID)