Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e496f8fb7e | |||
| fda016d011 | |||
| 082f577e17 | |||
| 78a4152471 | |||
| 3e55195831 | |||
| 9f5e76aee4 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
cmd/
|
cmd/
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.fleet/
|
||||||
|
.DS_Store
|
||||||
|
|||||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,13 +1,7 @@
|
|||||||
## Version 1.5.8
|
## Version 1.5.12
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Fix model the RecordK8CI to cloudbroker/k8ci/models to correctly receive information on get request
|
- Fix unhandled error in do() method for client and legacy-client
|
||||||
- Add model the RecordK8CIList to cloudbroker/k8ci/models to correctly receive information on list request
|
|
||||||
- Refactored clients to fix the problems with concurrency safety
|
|
||||||
- Add the Routes field in the CreateInRGRequest and CreateInAccountRequest models in cb/vins. The fields for creating the resource are matched
|
|
||||||
|
|
||||||
For get request to work correctly:
|
|
||||||
- Fix the Rules field (fix type) in the NATConfig model in cb/vins/models and ca/vins/models
|
|
||||||
- Fix the InfoVNF model (remove the excess field, add the Routes field) in cb/vins/models
|
|
||||||
- Add the ItemRoutes model in cb/vins/models
|
|
||||||
- Fix the RecordVINS model (remove the excess fields) in cb/vins/models
|
|
||||||
|
|||||||
42
client.go
42
client.go
@@ -140,24 +140,40 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
var resp *http.Response
|
// var resp *http.Response
|
||||||
var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
|
|
||||||
for i := uint64(0); i < dc.cfg.Retries; i++ {
|
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
req := req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err = dc.client.Do(req)
|
resp, err := dc.client.Do(req)
|
||||||
|
if err != nil || resp == nil {
|
||||||
if err == nil {
|
if strings.Contains(err.Error(),"connection reset by peer") {
|
||||||
if resp.StatusCode == 200 {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
|
time.Sleep(5 *time.Second)
|
||||||
|
resp, err = dc.client.Do(req)
|
||||||
|
if strings.Contains(err.Error(),"connection reset by peer") {
|
||||||
|
resp.Body.Close()
|
||||||
|
continue
|
||||||
|
} else if err == nil {
|
||||||
|
break
|
||||||
|
} else if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == 200 {
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
respBytes, _ := io.ReadAll(resp.Body)
|
||||||
|
err = fmt.Errorf("%s", respBytes)
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,24 +137,40 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
var resp *http.Response
|
// var resp *http.Response
|
||||||
var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
|
|
||||||
for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||||
req := req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err = ldc.client.Do(req)
|
resp, err := ldc.client.Do(req)
|
||||||
|
if err != nil || resp == nil {
|
||||||
if err == nil {
|
if strings.Contains(err.Error(),"connection reset by peer") {
|
||||||
if resp.StatusCode == 200 {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||||
|
time.Sleep(5 *time.Second)
|
||||||
|
resp, err = ldc.client.Do(req)
|
||||||
|
if strings.Contains(err.Error(),"connection reset by peer") {
|
||||||
|
resp.Body.Close()
|
||||||
|
continue
|
||||||
|
} else if err == nil {
|
||||||
|
break
|
||||||
|
} else if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == 200 {
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
respBytes, _ := io.ReadAll(resp.Body)
|
||||||
|
err = fmt.Errorf("%s", respBytes)
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user