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:
Kubernetes Prow Robot 2019-01-08 11:00:49 -08:00 committed by GitHub
commit b433108ead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View file

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

View file

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