From c9d31feb460a9eb1c05d660f522a0f80ca1f6c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9?= <12424564+craincn@user.noreply.gitee.com> Date: Mon, 11 Dec 2023 17:56:35 +0800 Subject: [PATCH] add: fix webhook & Filter the istio VirtualService retries field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵禹 <12424564+craincn@user.noreply.gitee.com> --- config/webhook/manifests.yaml | 1 + .../VirtualService/trafficRouting.lua | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 1c74221c..64ccd607 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -152,6 +152,7 @@ webhooks: - rollouts.kruise.io apiVersions: - v1alpha1 + - v1beta1 operations: - CREATE - UPDATE diff --git a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua index 1581c794..3f119398 100644 --- a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua +++ b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua @@ -19,6 +19,9 @@ function GetRulesToPatch(spec, stableService, protocol) local matchedRoutes = {} if (spec[protocol] ~= nil) then for _, rule in ipairs(spec[protocol]) do + if next(rule.retries) == nil then + rule.retries = nil + end -- skip routes contain matches if (rule.match == nil) then for _, route in ipairs(rule.route) do @@ -44,6 +47,13 @@ end -- generate routes with matches, insert a rule before other rules, only support http headers, cookies etc. function GenerateRoutesWithMatches(spec, matches, stableService, canaryService) + local http = spec.http + for _, rule in ipairs(http) do + if next(rule.retries) == nil then + rule.retries = nil + end + end + for _, match in ipairs(matches) do local route = {} route["match"] = {} @@ -79,7 +89,7 @@ function GenerateRoutesWithMatches(spec, matches, stableService, canaryService) else route.route[1].destination.host = canaryService end - table.insert(spec.http, 1, route) + table.insert(http, 1, route) end end