【发布时间】:2021-02-24 05:51:37
【问题描述】:
默认情况下,如果我们不定义任何VirtualService,Istio 将生成类似以下 Envoy 路由/重试配置:
{
"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"
}
但如果我们指定自己的VirtualService,例如:
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
生成的配置将如下所示:
{
"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"
}
请注意retriable_status_codes 丢失了。
对于默认值,看起来它是在https://github.com/istio/istio/blob/1.9.0/pilot/pkg/networking/core/v1alpha3/route/retry/retry.go#L38-L39 中定义的。但是没有通过VirtualService 配置retriable_status_codes 的选项/字段。
我们如何在 Istio 中定义 retriable_status_codes?
更新 #1:我的 Istio 版本是 1.6.9。但如果有更新的版本可以支持,也很感激。
【问题讨论】:
-
您好,您是否尝试将
retriable_status_codes添加到retryOn字段? -
嗨@DawidKruk,是的,已经添加了。我已经修改了上面的
VirtualService定义。生成的是正确的,它有retriable-status-codes,但是找不到我们在哪里可以设置要重试的状态码。 -
抱歉回复晚了,能否请您添加
5XX到retryOn?另外你能告诉你Istio的版本吗? -
我会避免添加
5xx,因为它将重试所有其他 5xx 错误代码(即 500、501、502、504 等)。和这里一样,我的目标是仅重试 503。我的 Istio 版本是 1.6.9。 -
据我所知,这是不可能的。我需要建议您使用您在此处提供的信息创建一个 github 问题 github.com/istio/istio/issues。
标签: istio envoyproxy istio-sidecar