Skip to content

Commit d43d032

Browse files
authoredDec 2, 2024
Merge pull request #4363 from antontroshin/resiliency-error-code-retries-docs
Add HTTP and gRPC error codes retries to the resiliency policies documentation
2 parents 2feaffb + 42e60e2 commit d43d032

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎daprdocs/content/en/operations/resiliency/policies.md

+22
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ The following retry options are configurable:
4949
| `duration` | Determines the time interval between retries. Only applies to the `constant` policy.<br/>Valid values are of the form `200ms`, `15s`, `2m`, etc.<br/> Defaults to `5s`.|
5050
| `maxInterval` | Determines the maximum interval between retries to which the `exponential` back-off policy can grow.<br/>Additional retries always occur after a duration of `maxInterval`. Defaults to `60s`. Valid values are of the form `5s`, `1m`, `1m30s`, etc |
5151
| `maxRetries` | The maximum number of retries to attempt. <br/>`-1` denotes an unlimited number of retries, while `0` means the request will not be retried (essentially behaving as if the retry policy were not set).<br/>Defaults to `-1`. |
52+
| `matching.httpStatusCodes` | Optional: a comma-separated string of HTTP status codes or code ranges to retry. Status codes not listed are not retried.<br/>Valid values: 100-599, [Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)<br/>Format: `<code>` or range `<start>-<end>`<br/>Example: "429,501-503"<br/>Default: empty string `""` or field is not set. Retries on all HTTP errors. |
53+
| `matching.gRPCStatusCodes` | Optional: a comma-separated string of gRPC status codes or code ranges to retry. Status codes not listed are not retried.<br/>Valid values: 0-16, [Reference](https://grpc.io/docs/guides/status-codes/)<br/>Format: `<code>` or range `<start>-<end>`<br/>Example: "1,501-503"<br/>Default: empty string `""` or field is not set. Retries on all gRPC errors. |
54+
55+
56+
{{% alert title="httpStatusCodes and gRPCStatusCodes format" color="warning" %}}
57+
The field values should follow the format as specified in the field description or in the "Example 2" below.
58+
An incorrectly formatted value will produce an error log ("Could not read resiliency policy") and `daprd` startup sequence will proceed.
59+
{{% /alert %}}
60+
5261

5362
The exponential back-off window uses the following formula:
5463

@@ -77,7 +86,20 @@ spec:
7786
maxRetries: -1 # Retry indefinitely
7887
```
7988

89+
Example 2:
8090

91+
```yaml
92+
spec:
93+
policies:
94+
retries:
95+
retry5xxOnly:
96+
policy: constant
97+
duration: 5s
98+
maxRetries: 3
99+
matches:
100+
httpStatusCodes: "429,500-599" # retry the HTTP status codes in this range. All others are not retried.
101+
gRPCStatusCodes: "1-4,8-11,13,14" # retry gRPC status codes in these ranges and separate single codes.
102+
```
81103

82104
## Circuit Breakers
83105

0 commit comments

Comments
 (0)