mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): avoid timeout for waiting azure async task
This commit is contained in:
@@ -17,6 +17,7 @@ package azure
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -638,15 +639,16 @@ func _jsonRequest(client *autorest.Client, method, domain, path string, body jso
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
location := func() string {
|
||||
locationFunc := func(head http.Header) string {
|
||||
for _, k := range []string{"Azure-Asyncoperation", "Location"} {
|
||||
link := header.Get(k)
|
||||
link := head.Get(k)
|
||||
if len(link) > 0 {
|
||||
return link
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}()
|
||||
}
|
||||
location := locationFunc(header)
|
||||
if len(location) > 0 {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < time.Minute*30 {
|
||||
@@ -681,6 +683,10 @@ func _jsonRequest(client *autorest.Client, method, domain, path string, body jso
|
||||
return nil, fmt.Errorf("Unknow status %s", status)
|
||||
}
|
||||
}
|
||||
location = locationFunc(_header)
|
||||
if len(location) == 0 && _body != nil {
|
||||
return _body, nil
|
||||
}
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
return nil, fmt.Errorf("time out for wait task %s %s", method, path)
|
||||
|
||||
Reference in New Issue
Block a user