-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix ingress updating for session-cookie-* annotation changes #3740
Fix ingress updating for session-cookie-* annotation changes #3740
Conversation
9d63dfa
to
c1c98d6
Compare
Side note: why does |
Because before the lua implementation we used |
@alexkursell @ElvinEfendi if this makes no sense now we could deprecate the annotation. |
@alexkursell please squash the commits |
@alexkursell you can remove all individual attributes at https://github.com/kubernetes/ingress-nginx/pull/3740/files#diff-8f83606fdd5dc8d2406cda71b9609762R21 now, since you're storing the whole config object now. |
This is a great find @alexkursell ! I'm sure chashsubset suffers from the similar issue since it's also skipping sync when endpoints don't change. cc @diegows |
be79d13
to
6e41383
Compare
Fixed |
ack, I'll check chashsubset this week. |
@@ -15,13 +15,10 @@ function _M.new(self, backend) | |||
local o = { | |||
instance = self.factory:new(nodes), | |||
cookie_name = backend["sessionAffinityConfig"]["cookieSessionAffinity"]["name"] or "route", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you keeping this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought it looked cleaner than or
ing it with "route"
in 2 different places. But this is probably more confusing, because everything else is in cookie_sesstion_affinity
. fixed.
return | ||
end | ||
|
||
for key, val in pairs(self:new(backend)) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not good - what you wanna do here is to update only the things that might change when self.cookie_session_affinity
changes. But right now you are also creating a new resty balancer instance and updating the instance of self with new one unnecessarily.
All you need to do here is to update cookie_session_affinity
and digest_func
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
20bb1f9
to
279bd0e
Compare
end) | ||
end) | ||
|
||
context("when backend does not specify cookie name", function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this test not necessary anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it because the actual cookie name wasn't being stored on the balancer anymore. I've added the test back and made it use a method on the balancer to check the cookie name.
@@ -4,24 +4,26 @@ local util = require("util") | |||
local ck = require("resty.cookie") | |||
|
|||
local _M = balancer_resty:new({ factory = resty_chash, name = "sticky" }) | |||
local default_cookie_name = "route" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention is to use uppercase for constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
if not cookie_path then | ||
cookie_path = ngx.var.location_path | ||
end | ||
|
||
local cookie_name = self.cookie_session_affinity.name or default_cookie_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could define a local function cookie_name
to avoid duplicate or
ing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. I defined a method so thatsticky_test.lua
can also use it to check that the logic is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we define local function in these cases and then conditionally export it for testing if _TEST
global variable is defined. But it's OK.
/lgtm |
90d3516
to
c180a09
Compare
@ElvinEfendi , sorry, needs another lgtm after I squashed the commits. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexkursell, ElvinEfendi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it: The
sticky
load balancer was ignoring changes inrequiring the creation of a new pod before the annotations were applied.
Which issue this PR fixes : fixes #3725
Special notes for your reviewer: @ElvinEfendi let me know if this change is big enough to add an e2e test.