add: fix webhook & Filter the istio VirtualService retries field

Signed-off-by: 赵禹 <12424564+craincn@user.noreply.gitee.com>
This commit is contained in:
赵禹 2023-12-11 17:56:35 +08:00
parent 9dcf3659d2
commit d016248d17
2 changed files with 12 additions and 1 deletions

View File

@ -152,6 +152,7 @@ webhooks:
- rollouts.kruise.io
apiVersions:
- v1alpha1
- v1beta1
operations:
- CREATE
- UPDATE

View File

@ -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