Skip to content

Commit

Permalink
Merge pull request #776 from imjaroiswebdev/revert-add-remaining-dela…
Browse files Browse the repository at this point in the history
…ys-for-retries

[CSGI-2263] Revert add remaining delays for retries
  • Loading branch information
imjaroiswebdev authored Dec 1, 2023
2 parents ce6be91 + 5a982b8 commit d112e20
Show file tree
Hide file tree
Showing 28 changed files with 6 additions and 174 deletions.
6 changes: 0 additions & 6 deletions pagerduty/data_source_pagerduty_event_orchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func dataSourcePagerDutyEventOrchestrationRead(d *schema.ResourceData, meta inte
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)
}

Expand All @@ -99,9 +96,6 @@ func dataSourcePagerDutyEventOrchestrationRead(d *schema.ResourceData, meta inte
// since the list ndpoint does not return it
orch, _, err := client.EventOrchestrations.Get(found.ID)
if err != nil {
// 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)
}

Expand Down
2 changes: 0 additions & 2 deletions pagerduty/data_source_pagerduty_event_orchestrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func dataSourcePagerDutyEventOrchestrationsRead(d *schema.ResourceData, meta int
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}

Expand Down Expand Up @@ -126,7 +125,6 @@ func dataSourcePagerDutyEventOrchestrationsRead(d *schema.ResourceData, meta int
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}
orchestrations = append(orchestrations, orch)
Expand Down
3 changes: 0 additions & 3 deletions pagerduty/resource_pagerduty_automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ func resourcePagerDutyAutomationActionsActionDelete(d *schema.ResourceData, meta
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)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ func resourcePagerDutyAutomationActionsActionServiceAssociationDelete(d *schema.
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)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ func resourcePagerDutyAutomationActionsActionTeamAssociationDelete(d *schema.Res
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)
}
return nil
Expand Down
3 changes: 0 additions & 3 deletions pagerduty/resource_pagerduty_automation_actions_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ func resourcePagerDutyAutomationActionsRunnerDelete(d *schema.ResourceData, meta
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)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ func resourcePagerDutyAutomationActionsRunnerTeamAssociationDelete(d *schema.Res
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)
}
return nil
Expand Down
6 changes: 0 additions & 6 deletions pagerduty/resource_pagerduty_business_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ func resourcePagerDutyBusinessServiceCreate(d *schema.ResourceData, meta interfa
}
log.Printf("[INFO] Creating PagerDuty business service %s", businessService.Name)
if businessService, _, err = client.BusinessServices.Create(businessService); err != nil {
// 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)
} else if businessService != nil {
d.SetId(businessService.ID)
Expand Down Expand Up @@ -138,9 +135,6 @@ func resourcePagerDutyBusinessServiceRead(d *schema.ResourceData, meta interface
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)
} else if businessService != nil {
d.Set("name", businessService.Name)
Expand Down
3 changes: 0 additions & 3 deletions pagerduty/resource_pagerduty_business_service_subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ func resourcePagerDutyBusinessServiceSubscriberCreate(d *schema.ResourceData, me

log.Printf("[INFO] Creating PagerDuty business service %s subscriber %s type %s", businessServiceId, businessServiceSubscriber.ID, businessServiceSubscriber.Type)
if _, err = client.BusinessServiceSubscribers.Create(businessServiceId, businessServiceSubscriber); err != nil {
// 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)
} else if businessServiceSubscriber != nil {
// create subscriber assignment it as PagerDuty API does not return one
Expand Down
4 changes: 0 additions & 4 deletions pagerduty/resource_pagerduty_escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ func resourcePagerDutyEscalationPolicyUpdate(d *schema.ResourceData, meta interf

retryErr := resource.Retry(5*time.Minute, func() *resource.RetryError {
if _, _, err := client.EscalationPolicies.Update(d.Id(), escalationPolicy); err != nil {
// 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 nil
Expand All @@ -225,7 +222,6 @@ func resourcePagerDutyEscalationPolicyDelete(d *schema.ResourceData, meta interf
retryErr := resource.Retry(30*time.Second, func() *resource.RetryError {
if _, err := client.EscalationPolicies.Delete(d.Id()); err != nil {
if isErrCode(err, 400) {
time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}

Expand Down
2 changes: 0 additions & 2 deletions pagerduty/resource_pagerduty_event_orchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func resourcePagerDutyEventOrchestrationCreate(d *schema.ResourceData, meta inte
retryErr := resource.Retry(10*time.Second, func() *resource.RetryError {
if orch, _, err := client.EventOrchestrations.Create(payload); err != nil {
if isErrCode(err, 400) || isErrCode(err, 429) {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
}

Expand Down Expand Up @@ -172,7 +171,6 @@ func resourcePagerDutyEventOrchestrationUpdate(d *schema.ResourceData, meta inte
retryErr := resource.Retry(10*time.Second, func() *resource.RetryError {
if _, _, err := client.EventOrchestrations.Update(d.Id(), orchestration); err != nil {
if isErrCode(err, 400) || isErrCode(err, 429) {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
Expand Down
22 changes: 0 additions & 22 deletions pagerduty/resource_pagerduty_event_orchestration_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,10 @@ func resourcePagerDutyEventOrchestrationIntegrationCreate(ctx context.Context, d
if isErrCode(err, 400) {
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)
} else if integration != nil {
// Try reading an integration after creation, retry if not found:
if _, readErr := fetchPagerDutyEventOrchestrationIntegration(ctx, d, meta, oid, integration.ID, true); readErr != nil {
time.Sleep(30 * time.Second)
log.Printf("[WARN] Cannot locate Integration '%s' on PagerDuty Event Orchestration '%s'. Retrying creation...", integration.ID, oid)
return resource.RetryableError(readErr)
}
Expand Down Expand Up @@ -155,9 +151,6 @@ func resourcePagerDutyEventOrchestrationIntegrationRead(ctx context.Context, d *
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)
}

Expand Down Expand Up @@ -192,9 +185,6 @@ func resourcePagerDutyEventOrchestrationIntegrationUpdate(ctx context.Context, d
if isErrCode(err, 400) {
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)
} else {
// try reading the migrated integration from destination and source:
Expand All @@ -203,14 +193,12 @@ func resourcePagerDutyEventOrchestrationIntegrationUpdate(ctx context.Context, d

// retry migration if the read request returned an error:
if readDestErr != nil {
time.Sleep(30 * time.Second)
log.Printf("[WARN] Integration '%s' cannot be found on the destination PagerDuty Event Orchestration '%s'. Retrying migration....", id, destinationOrchId)
return resource.RetryableError(readDestErr)
}

// retry migration if the integration still exists on the source:
if readSrcErr == nil && srcInt != nil {
time.Sleep(30 * time.Second)
log.Printf("[WARN] Integration '%s' still exists on the source PagerDuty Event Orchestration '%s'. Retrying migration....", id, sourceOrchId)
return resource.RetryableError(fmt.Errorf("Integration '%s' still exists on the source PagerDuty Event Orchestration '%s'.", id, sourceOrchId))
}
Expand Down Expand Up @@ -239,9 +227,6 @@ func resourcePagerDutyEventOrchestrationIntegrationUpdate(ctx context.Context, d
} else if integration != nil {
// Try reading an integration after updating the label, retry if the label is not updated:
if updInt, readErr := fetchPagerDutyEventOrchestrationIntegration(ctx, d, meta, oid, id, true); readErr != nil && updInt != nil {
// 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)
log.Printf("[WARN] Label for Integration '%s' on PagerDuty Event Orchestration '%s' was not updated. Expected: '%s', actual: '%s'. Retrying update...", id, oid, payload.Label, updInt.Label)
return resource.RetryableError(readErr)
}
Expand Down Expand Up @@ -274,14 +259,10 @@ func resourcePagerDutyEventOrchestrationIntegrationDelete(ctx context.Context, d
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)
} else {
// Try reading an integration after deletion, retry if still found:
if integr, _, readErr := client.EventOrchestrationIntegrations.GetContext(ctx, oid, id); readErr == nil && integr != nil {
time.Sleep(30 * time.Second)
log.Printf("[WARN] Integration '%s' still exists on PagerDuty Event Orchestration '%s'. Retrying deletion...", id, oid)
return resource.RetryableError(fmt.Errorf("Integration '%s' still exists on PagerDuty Event Orchestration '%s'.", id, oid))
}
Expand Down Expand Up @@ -314,9 +295,6 @@ func resourcePagerDutyEventOrchestrationIntegrationImport(ctx context.Context, d
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)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ func resourcePagerDutyEventOrchestrationPathGlobalUpdate(ctx context.Context, d
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
} else if response != nil {
d.SetId(response.OrchestrationPath.Parent.ID)
Expand Down Expand Up @@ -258,7 +257,6 @@ func resourcePagerDutyEventOrchestrationPathGlobalDelete(ctx context.Context, d
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func resourcePagerDutyEventOrchestrationPathRouterDelete(ctx context.Context, d
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}
return nil
Expand Down Expand Up @@ -210,7 +209,6 @@ func resourcePagerDutyEventOrchestrationPathRouterUpdate(ctx context.Context, d
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}
if response == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ func resourcePagerDutyEventOrchestrationPathServiceUpdate(ctx context.Context, d
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
} else if response != nil {
d.SetId(response.OrchestrationPath.Parent.ID)
Expand Down Expand Up @@ -359,7 +358,6 @@ func resourcePagerDutyEventOrchestrationPathServiceDelete(ctx context.Context, d
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ func resourcePagerDutyEventOrchestrationPathUnroutedDelete(ctx context.Context,
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}
return nil
Expand Down Expand Up @@ -260,7 +259,6 @@ func resourcePagerDutyEventOrchestrationPathUnroutedUpdate(ctx context.Context,
return resource.NonRetryableError(err)
}

time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}

Expand Down
14 changes: 0 additions & 14 deletions pagerduty/resource_pagerduty_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@ func resourcePagerDutyScheduleUpdate(d *schema.ResourceData, meta interface{}) e

retryErr := resource.Retry(2*time.Minute, func() *resource.RetryError {
if _, _, err := client.Schedules.Update(d.Id(), schedule, opts); err != nil {
// 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 nil
Expand Down Expand Up @@ -430,9 +427,6 @@ func resourcePagerDutyScheduleDelete(d *schema.ResourceData, meta interface{}) e
retryErr = resource.Retry(2*time.Minute, func() *resource.RetryError {
if _, err := client.Schedules.Delete(scheduleId); err != nil {
if !isErrCode(err, 400) {
// 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)
}
isErrorScheduleUsedByEP := func(e *pagerduty.Error) bool {
Expand Down Expand Up @@ -475,9 +469,6 @@ func resourcePagerDutyScheduleDelete(d *schema.ResourceData, meta interface{}) e
epsDataUsingThisSchedule, errFetchingFullEPs := fetchEPsDataUsingASchedule(epsUsingThisSchedule, client)
if errFetchingFullEPs != nil {
err = fmt.Errorf("%v; %w", err, errFetchingFullEPs)
// 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)
}

Expand All @@ -492,9 +483,6 @@ func resourcePagerDutyScheduleDelete(d *schema.ResourceData, meta interface{}) e
if workaroundErr != nil {
err = fmt.Errorf("%v; %w", err, workaroundErr)
}
// 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 nil
Expand Down Expand Up @@ -781,7 +769,6 @@ func removeScheduleFromEP(c *pagerduty.Client, scheduleID string, ep *pagerduty.
_, _, err := c.EscalationPolicies.Update(ep.ID, ep)
if err != nil {
if !isErrCode(err, 404) {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
}
}
Expand Down Expand Up @@ -876,7 +863,6 @@ func fetchEPsDataUsingASchedule(eps []string, c *pagerduty.Client) ([]*pagerduty
return resource.NonRetryableError(err)
}

time.Sleep(2 * time.Second)
return resource.RetryableError(err)
}
fullEPs = append(fullEPs, ep)
Expand Down
4 changes: 1 addition & 3 deletions pagerduty/resource_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,7 @@ func fetchService(d *schema.ResourceData, meta interface{}, errCallback func(err

errResp := errCallback(err, d)
if errResp != nil {
// 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)
time.Sleep(2 * time.Second)
return resource.RetryableError(errResp)
}

Expand Down
6 changes: 3 additions & 3 deletions pagerduty/resource_pagerduty_service_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ func resourcePagerDutyServiceDependencyAssociate(ctx context.Context, d *schema.

if err != nil {
if isErrCode(err, 404) {
// 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)
Expand Down Expand Up @@ -205,6 +202,7 @@ func resourcePagerDutyServiceDependencyDisassociate(ctx context.Context, d *sche
// 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)
} else if dependencies != nil {
for _, rel := range dependencies.Relationships {
Expand Down Expand Up @@ -249,6 +247,7 @@ func resourcePagerDutyServiceDependencyDisassociate(ctx context.Context, d *sche
// 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 nil
Expand Down Expand Up @@ -327,6 +326,7 @@ func findDependencySetState(ctx context.Context, depID, serviceID, serviceType s
// 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)
} else if dependencies != nil {
depFound := false
Expand Down
Loading

0 comments on commit d112e20

Please sign in to comment.