From 30dbda7d22997d2642a57cc4651f5eac06ce98b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9?= <12424564+craincn@user.noreply.gitee.com> Date: Wed, 3 Jan 2024 17:32:55 +0800 Subject: [PATCH 1/2] change: Support Istio getaway to filter VirtualService retries fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵禹 <12424564+craincn@user.noreply.gitee.com> --- .../VirtualService/trafficRouting.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua index 1581c794..825aa07c 100644 --- a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua +++ b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua @@ -19,6 +19,10 @@ function GetRulesToPatch(spec, stableService, protocol) local matchedRoutes = {} if (spec[protocol] ~= nil) then for _, rule in ipairs(spec[protocol]) do + local retries = rule.retries or {} + if #retries == 0 then + rule.retries = nil + end -- skip routes contain matches if (rule.match == nil) then for _, route in ipairs(rule.route) do @@ -44,6 +48,14 @@ 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 + local retries = rule.retries or {} + if #retries == 0 then + rule.retries = nil + end + end + for _, match in ipairs(matches) do local route = {} route["match"] = {} @@ -79,7 +91,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 From e5efd3c9e1a2af02dcd17a236d027e1cf188d82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9?= <12424564+craincn@user.noreply.gitee.com> Date: Wed, 3 Jan 2024 17:41:19 +0800 Subject: [PATCH 2/2] fixbug: Delete match with traffic judgment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵禹 <12424564+craincn@user.noreply.gitee.com> --- .../VirtualService/trafficRouting.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua index 825aa07c..41e48383 100644 --- a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua +++ b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua @@ -23,12 +23,10 @@ function GetRulesToPatch(spec, stableService, protocol) if #retries == 0 then rule.retries = nil end - -- skip routes contain matches - if (rule.match == nil) then - for _, route in ipairs(rule.route) do - if GetHost(route) == stableService then - table.insert(matchedRoutes, rule) - end + + for _, route in ipairs(rule.route) do + if GetHost(route) == stableService then + table.insert(matchedRoutes, rule) end end end @@ -134,4 +132,4 @@ else GenerateRoutes(spec, obj.stableService, obj.canaryService, obj.stableWeight, obj.canaryWeight, "tcp") GenerateRoutes(spec, obj.stableService, obj.canaryService, obj.stableWeight, obj.canaryWeight, "tls") end -return obj.data +return obj.data \ No newline at end of file