Skip to content

Commit

Permalink
Merge pull request #180 from NetApp/integration/main
Browse files Browse the repository at this point in the history
Sync bitbucket and GitHub
  • Loading branch information
wenjun666 authored Nov 16, 2023
2 parents f00f813 + abcf542 commit 2ee1ed9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 23.11.0
*ENHANCEMENTS: add retries when http returns >200 status code in getWorkingEnvironmentProperties.


## 23.10.0
BUG FIXES:
* resource/aws_fsx: handling for a situation in which the status does not exist yet.
Expand Down
15 changes: 13 additions & 2 deletions cloudmanager/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,18 +915,29 @@ func (c *Client) getWorkingEnvironmentProperties(apiRoot string, id string, fiel

var statusCode int
var response []byte
networkRetries := 3
networkRetries := 10
httpRetries := 10 // retry if API returns non 200 status code
for {
code, result, _, err := c.CallAPIMethod("GET", baseURL, nil, c.Token, hostType, clientID)
if err != nil {
log.Printf("network error %v", err)
if networkRetries > 0 {
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)
networkRetries--
} else {
log.Printf("getWorkingEnvironmentProperties %s request failed (%d) %s", baseURL, statusCode, err)
return workingEnvironmentOntapClusterPropertiesResponse{}, err
}
} else {
if code > 400 { //client error or server error
log.Printf("http status code %v", code)
log.Printf("http response %s", result)
if httpRetries > 0 {
time.Sleep(10 * time.Second)
httpRetries--
continue
}
}
statusCode = code
response = result
break
Expand Down

0 comments on commit 2ee1ed9

Please sign in to comment.