0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

istioのretry設定

Last updated at Posted at 2024-12-27

OpenShift Service Mesh(2.5)管理下のアプリケーションへのリクエストが勝手にretryされていたので調査。

1. デフォルト設定

istio-proxyの設定を確認。デフォルトのretry_policyだと5xxエラーなどの際に2回リトライする設定となっている。

$ oc rsh -c istio-proxy test-pod curl -s http://localhost:15000/config_dump |jq '.configs[] | select(.dynamic_route_configs) | .dynamic_route_configs[] | .route_config.virtual_hosts[] | select(.name == "test.hoge.svc.cluster.local:80")' 

{
  "name": "test.hoge.svc.cluster.local:80",
  "domains": [
    "test.hoge.svc.cluster.local",
    "172.21.24.200"
  ],
  "routes": [
    {
      "match": {
        "prefix": "/"
      },
      "route": {
        "cluster": "outbound|80||test.hoge.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",
              "typed_config": {
                "@type": "type.googleapis.com/envoy.extensions.retry.host.previous_hosts.v3.PreviousHostsPredicate"
              }
            }
          ],
          "host_selection_retry_max_attempts": "5",
          "retriable_status_codes": [
            503
          ]
        },
        "max_grpc_timeout": "0s"
      },
      "decorator": {
        "operation": "test.hoge.svc.cluster.local:80/*"
      },
      "name": "default"
    }
  ],
  "include_request_attempt_count": true
}

2. 設定方法

デフォルト設定を変更したい場合、VirtualServiceretriesフィールドを明示的に設定する。

設定例

spec:
  hosts:
    - test
  http:
    - route:
        - destination:
            host: test
      retries:
        attempts: 5          
        perTryTimeout: 1s           
        retryOn: "5xx,connect-failure,refused-stream"
  • attempts:リトライ回数。無効にしたい場合は0とする
  • perTryTimeout:各リトライのタイムアウト時間。
  • retryOn:リトライ条件。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?