Merge branch 'release/2.4.0' of ssh://git.yunion.io/~qiujian/onecloud into hotfix/qj-resolve-conflict-2.5.0-20190107

Conflicts:
	pkg/util/aliyun/aliyun.go
This commit is contained in:
Qiu Jian
2019-01-07 21:39:00 +08:00
4 changed files with 41 additions and 3 deletions
+31
View File
@@ -0,0 +1,31 @@
package cloudprovider
import (
"strings"
"time"
)
func IsError(err error, errs []string) bool {
for i := range errs {
if strings.Index(err.Error(), errs[i]) >= 0 {
return true
}
}
return false
}
func RetryOnError(tryFunc func() error, errs []string, maxTries int) error {
tried := 0
for tried < maxTries {
err := tryFunc()
if err == nil {
return nil
}
if err != nil && !IsError(err, errs) {
return err
}
tried += 1
time.Sleep(10 * time.Duration(tried) * time.Second)
}
return ErrTimeout
}
+1 -1
View File
@@ -1213,7 +1213,7 @@ func (self *SGuest) StartGuestDetachdiskTask(ctx context.Context, userCred mccli
})
}
disk.SetStatus(userCred, DISK_DETACHING, "")
return self.GetDriver().StartGuestDetachdiskTask(ctx, userCred, self, taskData, "")
return self.GetDriver().StartGuestDetachdiskTask(ctx, userCred, self, taskData, parentTaskId)
}
func (self *SGuest) AllowPerformDetachIsolatedDevice(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
+1 -1
View File
@@ -83,7 +83,7 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str
resp, err := processCommonRequest(client, req)
if err != nil {
log.Errorf("request error %s parameters %s", err, params)
log.Errorf("request error %s with params %s", err, params)
return nil, err
}
body, err := jsonutils.Parse(resp.GetHttpContentBytes())
+8 -1
View File
@@ -512,7 +512,14 @@ func (self *SInstance) AttachDisk(ctx context.Context, diskId string) error {
}
func (self *SInstance) DetachDisk(ctx context.Context, diskId string) error {
return self.host.zone.region.DetachDisk(self.InstanceId, diskId)
return cloudprovider.RetryOnError(
func() error {
return self.host.zone.region.DetachDisk(self.InstanceId, diskId)
},
[]string{
`"Code":"InvalidOperation.Conflict"`,
},
4)
}
func (self *SRegion) GetInstance(instanceId string) (*SInstance, error) {