mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
阿里云API 错误重试
This commit is contained in:
@@ -47,14 +47,19 @@ func NewAliyunClient(providerId string, providerName string, accessKey string, s
|
||||
func jsonRequest(client *sdk.Client, apiName string, params map[string]string) (jsonutils.JSONObject, error) {
|
||||
for i := 1; i < 4; i++ {
|
||||
resp, err := _jsonRequest(client, "ecs.aliyuncs.com", ALIYUN_API_VERSION, apiName, params)
|
||||
retry := false
|
||||
if err != nil {
|
||||
for _, code := range []string{"SignatureNonceUsed", "InvalidInstance.NotSupported"} {
|
||||
if strings.Contains(err.Error(), code) {
|
||||
time.Sleep(time.Second * time.Duration(i*10))
|
||||
continue
|
||||
retry = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if retry {
|
||||
time.Sleep(time.Second * time.Duration(i*10))
|
||||
continue
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
return nil, fmt.Errorf("timeout for request %s params: %s", apiName, params)
|
||||
|
||||
Reference in New Issue
Block a user