Skip to content

Commit cacf5f4

Browse files
authored
Add docs for custom retry handling (GoogleCloudPlatform#12248)
1 parent e8a9b97 commit cacf5f4

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/content/develop/custom-code.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,28 @@ The parameters the function receives are:
206206
- `d`: Terraform resource data. Use `d.Get("field_name")` to get a field's current value.
207207
- `meta`: Can be cast to a Config object (which can make API calls) using `meta.(*transport_tpg.Config)`
208208

209+
### Custom retry handling
210+
211+
```yaml
212+
error_retry_predicates:
213+
- 'transport_tpg.IamMemberMissing'
214+
215+
error_abort_predicates:
216+
- 'transport_tpg.Is429QuotaError'
217+
```
218+
219+
Use `error_retry_predicates` or `error_abort_predicates` functions to retry or abort when encountering certain error responses. By default, errors are retried using [this list](https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/third_party/terraform/transport/error_retry_predicates.go#L23) of retry predicates. `error_retry_predicates` can be used to make more errors retryable, while `error_abort_predicates` can be used to prevent errors from being retried.
220+
221+
Both functions use the following signature:
222+
223+
```go
224+
func (err error) (bool, string) {}
225+
```
226+
227+
The function takes an error and returns:
228+
- `bool`: whether the error should be retried/aborted
229+
- `string`: a reason that will be logged
230+
209231
## Replace entire CRUD methods
210232

211233
```yaml

docs/content/develop/resource-reference.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,24 @@ async:
239239
resource_inside_response: true
240240
```
241241

242+
### `error_retry_predicates`
243+
244+
An array of function names that determine whether an error is retryable.
245+
246+
```yaml
247+
error_retry_predicates:
248+
- 'transport_tpg.IamMemberMissing'
249+
```
250+
251+
### `error_abort_predicates`
252+
253+
An array of function names that determine whether an error is not retryable.
254+
255+
```yaml
256+
error_abort_predicates:
257+
- 'transport_tpg.Is429QuotaError'
258+
```
259+
242260
## IAM resources
243261

244262
### `iam_policy`

0 commit comments

Comments
 (0)