Merge pull request #3634 from Shopify/hyphen-in-canary-by-cookie
canary by cookie should support hypen in cookie name
This commit is contained in:
commit
b433108ead
2 changed files with 8 additions and 10 deletions
|
@ -157,9 +157,8 @@ local function route_to_alternative_balancer(balancer)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local clean_target_header = util.replace_special_char(traffic_shaping_policy.header, "-", "_")
|
local target_header = util.replace_special_char(traffic_shaping_policy.header, "-", "_")
|
||||||
|
local header = ngx.var["http_" .. target_header]
|
||||||
local header = ngx.var["http_" .. clean_target_header]
|
|
||||||
if header then
|
if header then
|
||||||
if header == "always" then
|
if header == "always" then
|
||||||
return true
|
return true
|
||||||
|
@ -168,9 +167,8 @@ local function route_to_alternative_balancer(balancer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local clean_target_cookie = util.replace_special_char(traffic_shaping_policy.cookie, "-", "_")
|
local target_cookie = traffic_shaping_policy.cookie
|
||||||
|
local cookie = ngx.var["cookie_" .. target_cookie]
|
||||||
local cookie = ngx.var["cookie_" .. clean_target_cookie]
|
|
||||||
if cookie then
|
if cookie then
|
||||||
if cookie == "always" then
|
if cookie == "always" then
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -473,7 +473,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
|
||||||
|
|
||||||
canaryAnnotations := map[string]string{
|
canaryAnnotations := map[string]string{
|
||||||
"nginx.ingress.kubernetes.io/canary": "true",
|
"nginx.ingress.kubernetes.io/canary": "true",
|
||||||
"nginx.ingress.kubernetes.io/canary-by-cookie": "CanaryByCookie",
|
"nginx.ingress.kubernetes.io/canary-by-cookie": "Canary-By-Cookie",
|
||||||
}
|
}
|
||||||
|
|
||||||
canaryIngName := fmt.Sprintf("%v-canary", host)
|
canaryIngName := fmt.Sprintf("%v-canary", host)
|
||||||
|
@ -488,7 +488,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
|
||||||
resp, body, errs := gorequest.New().
|
resp, body, errs := gorequest.New().
|
||||||
Get(f.IngressController.HTTPURL).
|
Get(f.IngressController.HTTPURL).
|
||||||
Set("Host", host).
|
Set("Host", host).
|
||||||
AddCookie(&http.Cookie{Name: "CanaryByCookie", Value: "always"}).
|
AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "always"}).
|
||||||
End()
|
End()
|
||||||
|
|
||||||
Expect(errs).Should(BeEmpty())
|
Expect(errs).Should(BeEmpty())
|
||||||
|
@ -500,7 +500,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
|
||||||
resp, body, errs = gorequest.New().
|
resp, body, errs = gorequest.New().
|
||||||
Get(f.IngressController.HTTPURL).
|
Get(f.IngressController.HTTPURL).
|
||||||
Set("Host", host).
|
Set("Host", host).
|
||||||
AddCookie(&http.Cookie{Name: "CanaryByCookie", Value: "never"}).
|
AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "never"}).
|
||||||
End()
|
End()
|
||||||
|
|
||||||
Expect(errs).Should(BeEmpty())
|
Expect(errs).Should(BeEmpty())
|
||||||
|
@ -513,7 +513,7 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
|
||||||
resp, body, errs = gorequest.New().
|
resp, body, errs = gorequest.New().
|
||||||
Get(f.IngressController.HTTPURL).
|
Get(f.IngressController.HTTPURL).
|
||||||
Set("Host", host).
|
Set("Host", host).
|
||||||
AddCookie(&http.Cookie{Name: "CanaryByCookie", Value: "badcookievalue"}).
|
AddCookie(&http.Cookie{Name: "Canary-By-Cookie", Value: "badcookievalue"}).
|
||||||
End()
|
End()
|
||||||
|
|
||||||
Expect(errs).Should(BeEmpty())
|
Expect(errs).Should(BeEmpty())
|
||||||
|
|
Loading…
Reference in a new issue