Skip to content

Commit

Permalink
Merge pull request #286 from stmcallister/user-update-retry
Browse files Browse the repository at this point in the history
adding retry to user update
  • Loading branch information
Scott McAllister authored Jan 5, 2021
2 parents dbabde8 + 43132a9 commit 8c73795
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pagerduty/resource_pagerduty_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,20 @@ func resourcePagerDutyUserUpdate(d *schema.ResourceData, meta interface{}) error

log.Printf("[INFO] Updating PagerDuty user %s", d.Id())

if _, _, err := client.Users.Update(d.Id(), user); err != nil {
return err
// Retrying to give other resources (such as escalation policies) to delete
retryErr := resource.Retry(2*time.Minute, func() *resource.RetryError {
if _, _, err := client.Users.Update(d.Id(), user); err != nil {
if isErrCode(err, 400) {
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
}
return nil
})
if retryErr != nil {
time.Sleep(2 * time.Second)
return retryErr
}

if d.HasChange("teams") {
Expand Down

0 comments on commit 8c73795

Please sign in to comment.