Compare commits

...

10 Commits

Author SHA1 Message Date
332bd7f560 v1.5.16 2023-12-05 16:28:12 +03:00
10d6e90dfe v1.5.15 2023-12-01 17:48:41 +03:00
0183f50cc8 v1.5.14 2023-12-01 12:58:44 +03:00
888923c6ce v1.5.13 2023-11-30 15:01:53 +03:00
e496f8fb7e v1.5.12 2023-11-30 10:55:00 +03:00
fda016d011 v1.5.11 2023-11-29 11:57:03 +03:00
082f577e17 v1.5.9 2023-09-27 14:46:23 +03:00
78a4152471 v1.6.0-zeta 2023-09-25 19:11:33 +03:00
3e55195831 1.6.0-epsilon 2023-09-24 14:41:21 +03:00
9f5e76aee4 1.6.0-delta 2023-09-24 12:11:31 +03:00
4 changed files with 62 additions and 38 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,5 @@
cmd/
.idea/
.vscode/
.vscode/
.fleet/
.DS_Store

View File

@@ -1,13 +1,4 @@
## Version 1.5.8
## Version 1.5.16
### Bugfix
- Fix model the RecordK8CI to cloudbroker/k8ci/models to correctly receive information on get request
- 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
- Fix EOF error by closing request

View File

@@ -140,24 +140,37 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
req.Header.Set("Accept", "application/json")
var resp *http.Response
var err error
buf, _ := io.ReadAll(req.Body)
for i := uint64(0); i < dc.cfg.Retries; i++ {
req := req.Clone(req.Context())
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err = dc.client.Do(req)
if err == nil {
if resp.StatusCode == 200 {
return resp, err
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req)
req.Close = true
if err != nil || resp == nil {
if strings.Contains(err.Error(), "connection reset by peer") || errors.Is(err, io.EOF) {
for i := uint64(0); i < dc.cfg.Retries; i++ {
time.Sleep(5 * time.Second)
resp, err = dc.client.Do(req)
if err == nil {
break
}
if strings.Contains(err.Error(), "connection reset by peer") || errors.Is(err, io.EOF) {
continue
}
if err != nil {
return nil, err
}
}
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
}
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)
}

View File

@@ -137,24 +137,42 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Accept", "application/json")
var resp *http.Response
var err error
// var resp *http.Response
// var err error
buf, _ := io.ReadAll(req.Body)
for i := uint64(0); i < ldc.cfg.Retries; i++ {
req := req.Clone(req.Context())
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err = ldc.client.Do(req)
if err == nil {
if resp.StatusCode == 200 {
return resp, err
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
// req = req.Clone(req.Context())
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := ldc.client.Do(req)
req.Close = true
if err != nil || resp == nil {
if strings.Contains(err.Error(), "connection reset by peer") || errors.Is(err, io.EOF) {
for i := uint64(0); i < ldc.cfg.Retries; i++ {
time.Sleep(5 * time.Second)
resp, err = ldc.client.Do(req)
if err == nil {
break
}
if strings.Contains(err.Error(), "connection reset by peer") || errors.Is(err, io.EOF) {
continue
}
if err != nil {
return nil, err
}
}
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
}
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)
}