Skip to content

Commit

Permalink
Merge pull request #1096 from seokho-son/main
Browse files Browse the repository at this point in the history
Trials for inspectResourcesOverview to prevent rateLimitExceeded from CSP
  • Loading branch information
seokho-son authored May 7, 2022
2 parents 59dc654 + d11af31 commit 3e56a9b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/mcis/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,22 @@ func InspectResourcesOverview() (InspectResourceAllResult, error) {
common.CBLog.Error(err)
temp.SystemMessage = err.Error()
}
// retry if request rateLimitExceeded occurs. (GCP has ratelimiting)
rateLimitMessage := "limit"
maxTrials := 5
if strings.Contains(temp.SystemMessage, rateLimitMessage) {
for i := 0; i < maxTrials; i++ {
common.RandomSleep(40, 80)
inspectResult, err = InspectResources(k.ConfigName, common.StrVNet)
if err != nil {
common.CBLog.Error(err)
temp.SystemMessage = err.Error()
} else {
temp.SystemMessage = ""
break
}
}
}
temp.TumblebugOverview.VNet = inspectResult.ResourceOverview.OnTumblebug
temp.CspTotalOverview.VNet = inspectResult.ResourceOverview.OnCspTotal

Expand Down

0 comments on commit 3e56a9b

Please sign in to comment.