Skip to content

Commit

Permalink
UptimeCheckConfig custom delete for 400s (#9429)
Browse files Browse the repository at this point in the history
[upstream:c607d1f0236f684036c7a461bbc832ca40e54b0e]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Nov 14, 2023
1 parent 15be250 commit 9e1c161
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/9429.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
monitoring: Added error message for `google_monitoring_uptime_check_config` deletes on 400 response to delete Alert Policies first.
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"strings"
"time"

"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

Expand Down Expand Up @@ -847,7 +848,12 @@ func resourceMonitoringUptimeCheckConfigDelete(d *schema.ResourceData, meta inte
Timeout: d.Timeout(schema.TimeoutDelete),
ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError},
})

if err != nil {
if transport_tpg.IsGoogleApiErrorWithCode(err, 400) {
err := fmt.Errorf("%w - please ensure all associated Alert Policies are deleted.", err)
return errwrap.Wrapf("Error when reading or editing UptimeCheckConfig: {{err}}", err)
}
return transport_tpg.HandleNotFoundError(err, d, "UptimeCheckConfig")
}

Expand Down

0 comments on commit 9e1c161

Please sign in to comment.