-
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
Document for cookie expires annotation #3363
Conversation
@@ -50,13 +54,13 @@ Date: Fri, 10 Feb 2017 14:11:12 GMT | |||
Content-Type: text/html | |||
Content-Length: 612 | |||
Connection: keep-alive | |||
Set-Cookie: INGRESSCOOKIE=a9907b79b248140b56bb13723f72b67697baac3d; Path=/; HttpOnly | |||
Set-Cookie: INGRESSCOOKIE=a9907b79b248140b56bb13723f72b67697baac3d; Expires=Wed, 07-Nov-18 09:05:06 GMT; Max-Age=172800; Path=/; HttpOnly |
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.
Are you sure this is the correct expiry given the annotation is set to 172800? Isn’t the annotation value a Unix timestamp ?
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.
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.
@ElvinEfendi Any more comments?
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.
@skeeey as you can see from your screenshot it is set to 03 January 1970
which is expected given the way you implemented the feature. However in the docs you say it will be 07 Nov 2018
.
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.
@ElvinEfendi, for my screenshot, it is dev environment, I do not adjust the system time (the initial system time is 01 January 1970
), so the result is 03 January 1970
, but for document, I think, if user adjust his system time, it is more close to real world, Do you think we should keep the result as dev environment? if it is the expected, I can change 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.
01 January 1970
is Unix epoch time, same in every Unix based system.
@ElvinEfendi ping |
@@ -11,6 +11,8 @@ Session stickiness is achieved through 3 annotations on the Ingress, as shown in | |||
|nginx.ingress.kubernetes.io/affinity|Sets the affinity type|string (in NGINX only ``cookie`` is possible| | |||
|nginx.ingress.kubernetes.io/session-cookie-name|Name of the cookie that will be used|string (default to INGRESSCOOKIE)| | |||
|nginx.ingress.kubernetes.io/session-cookie-hash|Type of hash that will be used in cookie value|sha1/md5/index| | |||
|nginx.ingress.kubernetes.io/session-cookie-expires|Number of seconds until the cookie expires that will correspond to cookie `Expires` directive|number of seconds| |
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 an accurate description. This value is rather a date as UNIX timestamp that the cookie will expire on.
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.
change this to
|nginx.ingress.kubernetes.io/session-cookie-expires|The value is rather a date as UNIX timestamp that the cookie will expire on, it will correspond to cookie `Expires` directive|UNIX timestamp|
Do you think this is OK or not?
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.
Looks good with a slight adjustment to the description as following:
The value is a date as UNIX timestamp that the cookie will expire on, it corresponds to cookie
Expires
directive
@skeeey I think there's a flaw in the implementation. Let's say as in your example we set |
@ElvinEfendi, you are right, I examine the current implementation, I think the implementation is right, I use if self.cookie_expires and self.cookie_expires ~= "" then
cookie_data.expires = ngx.cookie_time(tonumber(self.cookie_expires))
end so the behavior should be our expected, the problem is the document is wrong, so I plan to update the example to nginx.ingress.kubernetes.io/session-cookie-expires: "1546912535"
nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" to distinguish the and this example will yield
Do you think this is OK or not? |
@skeeey the problem is here, it should look like this:
otherwise as I explained at #3363 (comment) everyone is going to get same |
@ElvinEfendi, I am confused by timestamp :), yes, I should add it, I correct the code and document, please see the new code diff, thanks BTW, the current example date is |
@ElvinEfendi, the CI test failed, would you have a look? because I can run the test in my environment successfully |
test/e2e/annotations/affinity.go
Outdated
@@ -219,7 +219,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", | |||
Expect(resp.StatusCode).Should(Equal(http.StatusOK)) | |||
local, _ := time.LoadLocation("GMT") | |||
duration, _ := time.ParseDuration("48h") | |||
expected := time.Date(1970, time.January, 1, 0, 0, 0, 0, local).Add(duration).Format("Mon, 02-Jan-06 15:04:05 MST") | |||
expected := time.Now().In(local).Add(duration).Format("Mon, 02-Jan-06 15:04:05 MST") |
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 going to be flaky. Imagine you send the request at the very end of a second and by the time this code is being evaluated next second starts. Then the assertion below won't succeed because actual datetime will have second n
, whereas expected will have n+1
I suggest you drop seconds from the format and leave only minute granularity.
@skeeey this is looking good now. Once you address https://github.com/kubernetes/ingress-nginx/pull/3363/files#r246778598 please squash your commits. |
/check-cla |
@ElvinEfendi ping (last PR to be included in 0.22) |
@@ -11,6 +11,8 @@ Session stickiness is achieved through 3 annotations on the Ingress, as shown in | |||
|nginx.ingress.kubernetes.io/affinity|Sets the affinity type|string (in NGINX only ``cookie`` is possible| | |||
|nginx.ingress.kubernetes.io/session-cookie-name|Name of the cookie that will be used|string (default to INGRESSCOOKIE)| | |||
|nginx.ingress.kubernetes.io/session-cookie-hash|Type of hash that will be used in cookie value|sha1/md5/index| | |||
|nginx.ingress.kubernetes.io/session-cookie-expires|The value is a date as UNIX timestamp that the cookie will expire on, it corresponds to cookie Expires directive|number of seconds| |
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 accurate now that we made this annotation to accept number of seconds as well (it gets appended to current time to generate date for Expires attribute)
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ElvinEfendi, skeeey 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:
Document for cookie expires annotation
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
/assign @ElvinEfendi