diff --git a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua index 1581c794..41e48383 100644 --- a/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua +++ b/lua_configuration/networking.istio.io/VirtualService/trafficRouting.lua @@ -19,12 +19,14 @@ function GetRulesToPatch(spec, stableService, protocol) local matchedRoutes = {} if (spec[protocol] ~= nil) then for _, rule in ipairs(spec[protocol]) do - -- 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 + local retries = rule.retries or {} + if #retries == 0 then + rule.retries = nil + end + + for _, route in ipairs(rule.route) do + if GetHost(route) == stableService then + table.insert(matchedRoutes, rule) end end end @@ -44,6 +46,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 +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 @@ -122,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