Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HashOnCookie and HashOnCookiePath are not propagated through the Ingress Controller #132

Closed
jdevalk2 opened this issue Sep 19, 2018 · 4 comments

Comments

@jdevalk2
Copy link
Contributor

jdevalk2 commented Sep 19, 2018

Summary

How each request is routed to which backend server is determined by HashOn setting.

One strategy is to write a cookie in the request so that the next request that comes in can be routed to the same backend server (stick session).

Setting a route with HashOn strategy based on Cookie, the HashOnCookie and HashOnCookiePath are never parsed and thus ignored.
By being empty the HashOn strategy can never be set to cookie in Kong Ingress Controller rule specification.

Note I have an initial patch for this below.

Kubernetes version

1.11.3

Environment

Azure AKS

What happened

Trying to set the hash strategy to cookie, without success.
Upon investigation it seems that the code is not there to propagate HashOnCookie and HashOnCookiePath. So these values are always empty.

Because they are not parsed and empty, the Cookie setting itself is also flagged as invalid.

Expected behaviour

I can set HashOn strategy to Cookie
I can set the HashOnCookie and HashOnCookiePath and when I then look in the Kong database, I can see those settings persisted and used by the Kong api gateway.

Steps To Reproduce

---
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: stuff-ingress-rule
  annotations:
    kubernetes.io/ingress.class: "nginx"
proxy:
  path: "/urlendpoint/stuffdata"
route:
  methods:
  - GET
  - POST
  strip_path: true
  preserve_host: false
upstream:
  **hash_on_cookie: "sessionAffinity"
  hash_on: "cookie"
  hash_fallback: "none"
  hash_on_cookie_path: "/"**
@jdevalk2
Copy link
Contributor Author

jdevalk2 commented Sep 19, 2018

Types.go line 119

type Upstream struct {
	Required `json:",inline"`

	Name string `json:"name"`

	HashOn           string        `json:"hash_on,omitempty"`
	HashFallback     string        `json:"hash_fallback,omitempty"`
	HashOnHeader     string        `json:"hash_on_header,omitempty"`
	HashOnCookie     string        `json:"hash_on_cookie,omitempty"`    // Added
	HashOnCookiePath string        `json:"hash_on_cookie_path,omitempty"` // Added
	Healthchecks     *Healthchecks `json:"healthchecks,omitempty"`
	Slots            int           `json:"slots,omitempty"`
}

Kong.go line 126

			if res.StatusCode == http.StatusNotFound {
				upstream := kongadminv1.NewUpstream(upstreamName)

				if kongIngress != nil && kongIngress.Upstream != nil {
					if kongIngress.Upstream.HashOn != "" {
						upstream.HashOn = kongIngress.Upstream.HashOn
					}
/* Start added */
					if kongIngress.Upstream.HashOnCookie != "" {
						upstream.HashOnCookie = kongIngress.Upstream.HashOnCookie
					}

					if kongIngress.Upstream.HashOnCookiePath != "" {
						upstream.HashOnCookiePath = kongIngress.Upstream.HashOnCookiePath
					}
/* End added */

@hbagdi
Copy link
Member

hbagdi commented Sep 20, 2018

@jdevalk2 Do you mind sending a PR for this? Thanks!

@jdevalk2
Copy link
Contributor Author

I will send a PR though internally we are working on signing off on the CLA. When that is done I can submit a PR.

@hbagdi
Copy link
Member

hbagdi commented Sep 27, 2018

#139 was merged into master. Stay tuned for our next release!

@hbagdi hbagdi closed this as completed Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants