From 159fe2bfeb0b5cfef1b2113928e85240fc6c4393 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 19 May 2022 08:56:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=95=9C=E5=83=8F=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA20=E5=88=86?= =?UTF-8?q?=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/cloudbrain/resty.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/cloudbrain/resty.go b/modules/cloudbrain/resty.go index b5b86f31f..e70dbdd2b 100755 --- a/modules/cloudbrain/resty.go +++ b/modules/cloudbrain/resty.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "net/http" "strconv" "strings" @@ -359,10 +358,11 @@ func CommitAdminImage(params models.CommitImageParams) error { } func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime time.Time) { - attemps := 5 + attemps := 60 commitSuccess := false - time.Sleep(5 * time.Second) + for i := 0; i < attemps; i++ { + time.Sleep(20 * time.Second) log.Info("the " + strconv.Itoa(i) + " times query cloudbrain images.Imagetag:" + image.Tag + "isSetCreate:" + strconv.FormatBool(isSetCreatedUnix)) result, err := GetImagesPageable(1, pageSize, Custom, "") if err == nil && result.Code == "S000" { @@ -383,10 +383,6 @@ func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime tim if commitSuccess { break } - //第一次循环等待4秒,第二次等待4的2次方16秒,...,第5次。。。 ,总共大概是20多分钟内进行5次重试 - var sleepTime = time.Duration(int(math.Pow(4, (float64(i + 1))))) - - time.Sleep(sleepTime * time.Second) } if !commitSuccess {