From 389af0cc7fff0271f0c41a59bd4058f390242b67 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 7 Mar 2022 11:04:50 +0800 Subject: [PATCH] fix-bug --- modules/util/util.go | 2 +- routers/repo/modelarts.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/util/util.go b/modules/util/util.go index bd0f98556..134fd1296 100755 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -115,7 +115,7 @@ func AddZero(t int64) (m string) { func ConvertDisplayJobNameToJobName(DisplayName string) (JobName string) { t := time.Now() - JobName = "openi" + strings.ToLower(cutNameString(DisplayName, 15)) + "t" + t.Format("2006010215") + strconv.Itoa(int(rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(100000))) + JobName = "openi" + strings.ToLower(cutNameString(DisplayName, 15)) + "t" + t.Format("20060102150405")[4:] + strconv.Itoa(int(rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(100000))) return JobName } diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index b20cfeb8c..22a4226e4 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -329,9 +329,14 @@ func NotebookManage(ctx *context.Context) { var resultCode = "0" var errorMsg = "" var status = "" + task, err := models.GetCloudbrainByID(ID) + if err != nil { + log.Error("get task(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) + resultCode = "-1" + errorMsg = "system error" + } for { - task := ctx.Cloudbrain if action == models.ActionStop { if task.Status != string(models.ModelArtsRunning) { @@ -438,7 +443,7 @@ func NotebookDel(ctx *context.Context) { _, err := modelarts.DelNotebook2(task.JobID) if err != nil { log.Error("DelNotebook2(%s) failed:%v", task.JobName, err.Error()) - if strings.Contains(err.Error(), modelarts.NotebookNotFound) || strings.Contains(err.Error(), modelarts.NotebookNoPermission) || strings.Contains(err.Error(), modelarts.NotebookInvalid){ + if strings.Contains(err.Error(), modelarts.NotebookNotFound) || strings.Contains(err.Error(), modelarts.NotebookNoPermission) || strings.Contains(err.Error(), modelarts.NotebookInvalid) { log.Info("old notebook version") } else { ctx.RenderWithErr(err.Error(), tplDebugJobIndex, nil)