0

By default, if we don't define any VirtualService, Istio will generate something like the following Envoy route/retry configuration:

{
 "cluster": "outbound|9100||quote-svc-cip.quote.svc.cluster.local",
 "timeout": "0s",
 "retry_policy": {
  "retry_on": "connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes",
  "num_retries": 2,
  "retry_host_predicate": [
   {
    "name": "envoy.retry_host_predicates.previous_hosts"
   }
  ],
  "host_selection_retry_max_attempts": "5",
  "retriable_status_codes": [
   503
  ]
 },
 "max_grpc_timeout": "0s"
}

But if we specify our own VirtualService, e.g.:

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: book-svc-cip
  namespace: book
spec:
  hosts:
  - book-svc-cip.book.svc.cluster.local
  http:
  - retries:
      attempts: 3
      retryOn: connect-failure,refused-stream,unavailable,retriable-status-codes
    route:
    - destination:
        host: book-svc-cip.book.svc.cluster.local

The generated config will look like:

{
 "cluster": "outbound|9281||book-svc-cip.book.svc.cluster.local",
 "timeout": "0s",
 "retry_policy": {
  "retry_on": "connect-failure,refused-stream,unavailable,retriable-status-codes",
  "num_retries": 3,
  "retry_host_predicate": [
   {
    "name": "envoy.retry_host_predicates.previous_hosts"
   }
  ],
  "host_selection_retry_max_attempts": "5"
 },
 "max_grpc_timeout": "0s"
}

Notice that the retriable_status_codes is missing.

For the default, looks like it's defined in https://github.com/istio/istio/blob/1.9.0/pilot/pkg/networking/core/v1alpha3/route/retry/retry.go#L38-L39. But there is no option/field to configure retriable_status_codes via VirtualService.

How could we define the retriable_status_codes in Istio?

Update #1: My Istio version is 1.6.9. But if any newer version can support it, it's also appreciated.

Edward Samuel
  • 3,846
  • 1
  • 22
  • 39
  • Hello, have you tried to add the `retriable_status_codes` to the `retryOn` field? – Dawid Kruk Feb 24 '21 at 14:01
  • Hi @DawidKruk, yes, have added that. I have revised the `VirtualService` definition above. The generated one is correct, it has `retriable-status-codes` but could not find where can we set the status codes to be retried. – Edward Samuel Feb 25 '21 at 02:26
  • Apologies for a late reply, could you please add the `5XX` to `retryOn`? Also could you please tell your `Istio` version? – Dawid Kruk Mar 05 '21 at 12:52
  • I would avoid to add `5xx` as it will retry on all other 5xx error codes (i.e 500, 501, 502, 504, etc). As here, my goal is to retry only for 503. My Istio version is 1.6.9. – Edward Samuel Mar 09 '21 at 09:39
  • As fair as I know it is not possible. I need to advise you to create a github issue https://github.com/istio/istio/issues with the information that you provider here. – Dawid Kruk Mar 11 '21 at 13:00

2 Answers2

1

The example in the documentation should work (according to the source code); I can verify it works on a later version.

https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRetry

    retries:
      attempts: 3
      perTryTimeout: 2s
      retryOn: connect-failure,refused-stream,503

The source code for 1.6.9 shows that the above example should work

Cory Silva
  • 2,761
  • 17
  • 23
0

There is no direct Istio config available to update the retriable_status_codes in currently (v1.10.2).

But, we can do it via EnvoyFilter, e.g:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: retriable-status-codes-sidecar-outbound
  namespace: istio-system
spec:
  configPatches:
  - applyTo: HTTP_ROUTE
    match:
      context: SIDECAR_OUTBOUND
    patch:
      operation: MERGE
      value:
        route:
          retry_policy:
            retriable_status_codes:
            - 503

The above will inject the retriable_status_codes for outgoing calls on all sidecars (because we put it in istio-system namespace).

Edward Samuel
  • 3,846
  • 1
  • 22
  • 39