You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 20240917-BR-resiliency-error-code-retries.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,10 @@ It only focuses on the `retries` (https://docs.dapr.io/operations/resiliency/pol
10
10
11
11
## Background
12
12
13
-
In some applications, error codes may be used to indicate the business error, and retrying the operation might not be necessary or otherwise desirable.
13
+
In some applications, some status codes may be used to indicate the business error, and retrying the operation might not be necessary or otherwise desirable.
14
14
Customizing retry behavior will allow a more granular way to handle error codes that suit each use case.
15
15
Currently, all errors are retried when the policy is applied.
16
-
Some errors are not retryable, and subsequent calls will result in the same error, avoiding these retry calls will reduce the overall amount of requests, traffic, and errors.
16
+
Some status codes are not retryable, and subsequent calls will result in the same error. Avoiding these retry calls will reduce the overall number of requests, traffic, and errors.
Add a new object field to the `retries` policy Spec to allow the user to specify the error codes that should be retried.
42
+
Add a new object field to the `retries` policy Spec to allow the user to specify the status codes that should be retried.
43
43
Separate fields for HTTP and gRPC. The new fields should be optional and will default to the existing behavior, which is to retry on all errors.
44
44
45
45
### Example 1:
46
-
In this example, the retry policy will retry **_only_** on HTTP 500 and HTTP error range 502-504 (inclusive) and gRPC error range 2-4 (inclusive).
47
-
The rest of the errors will not be retried.
46
+
In this example, the retry policy will retry **_only_** on HTTP 500 and HTTP status code range 502-504 (inclusive) and gRPC status code range 2-4 (inclusive).
47
+
The rest of the status codes will not be retried.
48
48
49
49
```yaml
50
50
apiVersion: dapr.io/v1alpha1
@@ -66,8 +66,8 @@ spec:
66
66
```
67
67
68
68
### Example 2:
69
-
In this example, the retry policy will retry **_only_** on gRPC error range 1-15 (inclusive).
70
-
However, this policy will not apply to the HTTP errors, and they will be retried according to the default behavior, which is to retry on all errors.
69
+
In this example, the retry policy will retry **_only_** on gRPC status code range 1-15 (inclusive).
70
+
However, this policy will not apply to the HTTP status codes, and they will be retried according to the default behavior, which is to retry on all errors.
71
71
72
72
```yaml
73
73
apiVersion: dapr.io/v1alpha1
@@ -94,14 +94,14 @@ The acceptable values are the same as the ones defined in the [HTTP Status Codes
94
94
- gRPC: from 1 to 16
95
95
96
96
### Setting Format
97
-
Both the `httpStatusCodes` and `gRPCStatusCodes` fields are of type string and optional and can be set to a comma-separated list of error codes and/or ranges of error codes.
97
+
Both the `httpStatusCodes` and `gRPCStatusCodes` fields are of type string and optional and can be set to a comma-separated list of status codes and/or ranges of status codes.
98
98
The range must be in the format `<start>-<end>` (inclusive). Having more than one dash in the range is not allowed.
99
99
100
100
### Parsing the configuration
101
101
102
102
The configuration values will be first parsed as comma-separated lists.
103
-
Each entry in the list will be then parsed as a single error code or a range of error codes.
104
-
For invalid entries, the error will be logged when the policy is first loaded and the entry will be ignored, this will not fail the entire policy or the application start.
103
+
Each entry in the list will be then parsed as a single status code or a range of status codes.
104
+
Invalid entrieswill be logged and the application will fail to start.
105
105
106
106
Example:
107
107
@@ -124,15 +124,15 @@ spec:
124
124
```
125
125
The steps to parse the configuration are:
126
126
1. Split the `httpStatusCodes` configuration string `"500,502-504,15,404-405-500,-1,0,"` by the comma character resulting in the following list: `["500", "502-504", "15", "404-405-500", "-1", "0"]`ignoring the empty strings.
127
-
2. For each entry in the list, parse it as a single error code or a range of error codes.
128
-
3. If the entry is a single error code, add it to the list of error codes to retry.
129
-
4. If the entry is a range of error codes (each field for the relevant HTTP or gRPC error codes), add all the error codes in the range to the list of error codes to retry.
127
+
2. For each entry in the list, parse it as a single status code or a range of status codes.
128
+
3. If the entry is a single status code, add it to the list of status codes to retry.
129
+
4. If the entry is a range of status codes (each field for the relevant HTTP or gRPC status codes), add all the status codes in the range to the list of status codes to retry.
130
130
- 500 is **valid** code for HTTP
131
131
- 502-504 **valid** range of codes for HTTP
132
-
- 15 is **invalid** code for HTTP, error logged and entry ignored
133
-
- 404-405-500 is **invalid** range contains more than one dash, error logged and entry ignored
134
-
- -1 is ignored is **invalid** code for HTTP, error logged and entry ignored
135
-
- 0 is ignored is **invalid** code for HTTP, error logged and entry ignored
132
+
- 15 is **invalid** code for HTTP, error logged and application will fail to start
133
+
- 404-405-500 is **invalid** range contains more than one dash, error logged and application will fail to start
134
+
- -1 is ignored is **invalid** code for HTTP, error logged and application will fail to start
135
+
- 0 is ignored is **invalid** code for HTTP, error logged and application will fail to start
0 commit comments