Skip to content

Commit

Permalink
Merge pull request #507 from stmcallister/issue-476
Browse files Browse the repository at this point in the history
Addressing GOAWAY Error on a couple datasources
  • Loading branch information
imjaroiswebdev authored May 20, 2022
2 parents 9ddf6ce + 20ddd9c commit b9c8537
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ func dataSourcePagerDutyEscalationPolicyRead(d *schema.ResourceData, meta interf
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.EscalationPolicies.List(o)
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.EscalationPolicy
Expand Down
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ func dataSourcePagerDutyRulesetRead(d *schema.ResourceData, meta interface{}) er
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.Rulesets.List()
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.Ruleset
Expand Down

0 comments on commit b9c8537

Please sign in to comment.