Skip to content

Commit

Permalink
Merge pull request #959 from cjgajard/cjavier/fix-service-update-ag-r…
Browse files Browse the repository at this point in the history
…ules

Fix service update conflict on alert grouping rules
  • Loading branch information
cjgajard authored Dec 24, 2024
2 parents 403797b + e4a4daa commit 9f94c5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pagerduty/resource_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ func buildServiceStruct(d *schema.ResourceData) (*pagerduty.Service, error) {

if attr, ok := d.GetOk("alert_grouping"); ok {
ag := attr.(string)
service.AlertGrouping = &ag
if ag != "rules" {
service.AlertGrouping = &ag
}
}

if attr, ok := d.GetOk("alert_grouping_parameters"); ok {
Expand Down Expand Up @@ -525,6 +527,10 @@ func resourcePagerDutyServiceCreate(d *schema.ResourceData, meta interface{}) er

d.SetId(service.ID)

// We wait for internal subsystem to sync. Otherwise fields like
// alert_grouping_parameters will return empty.
time.Sleep(500 * time.Millisecond)

return fetchService(d, meta, genError)
}

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/resource_pagerduty_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func TestAccPagerDutyService_AlertGrouping(t *testing.T) {
// and will be removed in a future release.
}

func TestAccPagerDutyService_AlertContentGrouping(t *testing.T) {
func TestAccPagerDutyService_AlertGroupingContentBased(t *testing.T) {
username := fmt.Sprintf("tf-%s", acctest.RandString(5))
email := fmt.Sprintf("%[email protected]", username)
escalationPolicy := fmt.Sprintf("tf-%s", acctest.RandString(5))
Expand Down

0 comments on commit 9f94c5e

Please sign in to comment.