Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mmv1/third_party/terraform/tpgresource/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ func IsConflictError(err error) bool {
if e.Code == 409 || e.Code == 412 {
return true
}
} else if gErr := (*googleapi.Error)(nil); errors.As(err, &gErr) {
// For cases where the error is not wrapped by errwrap such in 409 IAM concurrency errors.
if gErr.Code == 409 || gErr.Code == 412 {
return true
}
}
return false
}
Expand Down
8 changes: 7 additions & 1 deletion mmv1/third_party/terraform/tpgresource/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,10 @@ func TestConflictError(t *testing.T) {
t.Error("did not find that a 409 was a conflict error.")
}
if !tpgresource.IsConflictError(errwrap.Wrapf("wrap", confErr)) {
t.Error("did not find that a wrapped 409 was a conflict error.")
t.Error("did not find that a wrapped (errwrap) 409 was a conflict error.")
}
if !tpgresource.IsConflictError(fmt.Errorf("wrap: %w", confErr)) {
t.Error("did not find that a wrapped (fmt.Errorf) 409 was a conflict error.")
}
confErr = &googleapi.Error{
Code: 412,
Expand All @@ -984,6 +987,9 @@ func TestConflictError(t *testing.T) {
if !tpgresource.IsConflictError(errwrap.Wrapf("wrap", confErr)) {
t.Error("did not find that a wrapped 412 was a conflict error.")
}
if !tpgresource.IsConflictError(fmt.Errorf("wrap: %w", confErr)) {
t.Error("did not find that a wrapped (fmt.Errorf) 412 was a conflict error.")
}
// skipping negative tests as other cases may be added later.
}

Expand Down
Loading