mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
hotfix: 避免上传镜像后,再次获取镜像列表因网络原因导致任务失败
This commit is contained in:
@@ -44,6 +44,8 @@ func (self *SZStackGuestDriver) DoScheduleMemoryFilter() bool { return true }
|
||||
|
||||
func (self *SZStackGuestDriver) DoScheduleSKUFilter() bool { return false }
|
||||
|
||||
func (self *SZStackGuestDriver) DoScheduleStorageFilter() bool { return true }
|
||||
|
||||
func (self *SZStackGuestDriver) GetHypervisor() string {
|
||||
return api.HYPERVISOR_ZSTACK
|
||||
}
|
||||
|
||||
@@ -316,14 +316,24 @@ func (cli *SZStackClient) _get(resource, resourceId string, spec string) (jsonut
|
||||
client := httputils.GetDefaultClient()
|
||||
header := http.Header{}
|
||||
requestURL := cli.getURL(resource, resourceId, spec)
|
||||
err := cli.sign(requestURL, "GET", header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, resp, err := httputils.JSONRequest(client, context.Background(), "GET", requestURL, header, nil, cli.debug)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, fmt.Sprintf("GET %s %s %s", resource, resourceId, spec))
|
||||
var resp jsonutils.JSONObject
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < time.Minute*5 {
|
||||
err := cli.sign(requestURL, "GET", header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, resp, err = httputils.JSONRequest(client, context.Background(), "GET", requestURL, header, nil, cli.debug)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "exceeded while awaiting headers") {
|
||||
time.Sleep(time.Second * 5)
|
||||
continue
|
||||
}
|
||||
return nil, errors.Wrapf(err, fmt.Sprintf("GET %s %s %s", resource, resourceId, spec))
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if resp.Contains("location") {
|
||||
location, _ := resp.GetString("location")
|
||||
return cli.wait(client, header, "get", requestURL, jsonutils.NewDict(), location)
|
||||
|
||||
Reference in New Issue
Block a user