Skip to content

Add a cookie strategy#89

Merged
jcmoraisjr merged 3 commits intojcmoraisjr:masterfrom
brianloss:cookie-stratgey
Feb 15, 2018
Merged

Add a cookie strategy#89
jcmoraisjr merged 3 commits intojcmoraisjr:masterfrom
brianloss:cookie-stratgey

Conversation

@brianloss
Copy link
Copy Markdown
Contributor

This is an additional annotation that will allow the user to select a different HAProxy cookie strategy other than insert. Supported additions are prefix and rewrite.

Copy link
Copy Markdown
Owner

@jcmoraisjr jcmoraisjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for supporting this controller! Just a few docs and logging changes.

Comment thread README.md Outdated
||`ingress.kubernetes.io/secure-backends`|[true\|false]|-|
||`ingress.kubernetes.io/secure-verify-ca-secret`|secret name|-|
||[`ingress.kubernetes.io/session-cookie-name`](#affinity)|cookie name|-|
|`[0]`|[`ingress.kubernetes.io/session-cookie-strategy`](#affinity)|cookie strategy|-|
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR belongs to v0.6, so use [1] instead and create also a * ``[1]`` only in ``snapshot`` tag entry just before this table.

Change also cookie strategy text to a list of options. Have a look at eg forwardfor configmap option.

ss, err := parser.GetStringAnnotation(annotationAffinityCookieStrategy, ing)

if err != nil || !affinityCookieStrategyRegex.MatchString(ss) {
glog.V(3).Infof("Invalid or no annotation value found in Ingress %v: %v. Setting it to default %v", ing.Name, annotationAffinityCookieStrategy, defaultAffinityCookieStrategy)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means an invalid configuration, so change the log level to glog.Warningf.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to a warning if there's an invalid strategy specified, but left as an info if there is no strategy specified since the intent was to have backwards compatibility and not require people to use this option. Otherwise, anyone who was using affinity but didn't set this would start getting warnings. Hope that's ok, but can change if necessary.

}

if nginxAffinity.CookieConfig.Strategy != "insert" {
t.Errorf("expected route as sticky-strategy but returned %v", nginxAffinity.CookieConfig.Strategy)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...expected insert as sticky-...

@brianloss
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

Copy link
Copy Markdown
Owner

@jcmoraisjr jcmoraisjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one new issue I just found, everything else is fine.


var (
affinityCookieHashRegex = regexp.MustCompile(`^(index|md5|sha1)$`)
affinityCookieStrategyRegex = regexp.MustCompile(`^(insert|prefix|rewrite)`)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an endline match $ here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix, thanks.

@jcmoraisjr jcmoraisjr added this to the v0.6 milestone Feb 15, 2018
@jcmoraisjr jcmoraisjr merged commit 8f717a3 into jcmoraisjr:master Feb 15, 2018
@jcmoraisjr
Copy link
Copy Markdown
Owner

Thank you very much, merged!

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

Successfully merging this pull request may close these issues.

2 participants