title: Istio Sidecar to retry on specified status codes (503)
body: <p>By default, if we don't define any <code>VirtualService</code>, Istio will generate something like the following Envoy route/retry configuration:</p>
  <pre class="lang-json prettyprint-override"><code>{
   &quot;cluster&quot;: &quot;outbound|9100||quote-svc-cip.quote.svc.cluster.local&quot;,
   &quot;timeout&quot;: &quot;0s&quot;,
   &quot;retry_policy&quot;: {
    &quot;retry_on&quot;: &quot;connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes&quot;,
    &quot;num_retries&quot;: 2,
    &quot;retry_host_predicate&quot;: [
     {
      &quot;name&quot;: &quot;envoy.retry_host_predicates.previous_hosts&quot;
     }
    ],
    &quot;host_selection_retry_max_attempts&quot;: &quot;5&quot;,
    &quot;retriable_status_codes&quot;: [
     503
    ]
   },
   &quot;max_grpc_timeout&quot;: &quot;0s&quot;
  }
  </code></pre>
  <p>But if we specify our own <code>VirtualService</code>, e.g.:</p>
  <pre class="lang-yaml prettyprint-override"><code>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
  </code></pre>
  <p>The generated config will look like:</p>
  <pre class="lang-json prettyprint-override"><code>{
   &quot;cluster&quot;: &quot;outbound|9281||book-svc-cip.book.svc.cluster.local&quot;,
   &quot;timeout&quot;: &quot;0s&quot;,
   &quot;retry_policy&quot;: {
    &quot;retry_on&quot;: &quot;connect-failure,refused-stream,unavailable,retriable-status-codes&quot;,
    &quot;num_retries&quot;: 3,
    &quot;retry_host_predicate&quot;: [
     {
      &quot;name&quot;: &quot;envoy.retry_host_predicates.previous_hosts&quot;
     }
    ],
    &quot;host_selection_retry_max_attempts&quot;: &quot;5&quot;
   },
   &quot;max_grpc_timeout&quot;: &quot;0s&quot;
  }
  </code></pre>
  <p>Notice that the <code>retriable_status_codes</code> is missing.</p>
  <p>For the default, looks like it's defined in <a href="https://github.com/istio/istio/blob/1.9.0/pilot/pkg/networking/core/v1alpha3/route/retry/retry.go#L38-L39" rel="nofollow noreferrer">https://github.com/istio/istio/blob/1.9.0/pilot/pkg/networking/core/v1alpha3/route/retry/retry.go#L38-L39</a>. But there is no option/field to configure <code>retriable_status_codes</code> via <code>VirtualService</code>.</p>
  <p>How could we define the <code>retriable_status_codes</code> in Istio?</p>
  <p>Update #1: My Istio version is <code>1.6.9</code>. But if any newer version can support it, it's also appreciated.</p>