-
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
Enable access log for default backend #3780
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Codecov Report
@@ Coverage Diff @@
## master #3780 +/- ##
=======================================
Coverage 54.82% 54.82%
=======================================
Files 82 82
Lines 6116 6116
=======================================
Hits 3353 3353
Misses 2368 2368
Partials 395 395 Continue to review full report at Codecov.
|
@aledbf Could you approve this PR? Without it very difficult to debug incoming requests to the ingress controller. |
@arturxx8 please add at least one e2e test (checking the log contains information about the request) and also squash the commits |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@arturxx8 please sign the CLA and squash the commits |
}) | ||
|
||
It("should not logging access to default backend when it disabled", func() { | ||
f.UpdateNginxConfigMapData("enable-access-log-for-default-backend", "true") |
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 should be set to "false", no?
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.
yes, this is mistake. I'm fixed it
|
||
logs, err := f.NginxLogs() | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(logs).To(ContainSubstring(`"/somethingTwo"`)) |
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.
And this should be ToNot
instead of To
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.
yes, this is mistake. I'm fixed it too
@@ -98,4 +98,35 @@ var _ = framework.IngressNginxDescribe("Default backend", func() { | |||
Expect(resp.StatusCode).Should(Equal(test.Status)) | |||
} | |||
}) | |||
It("should logging access to default backend when it enabled", 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.
Please change the title to something like
enables access logging for default backend
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.
Thanks, I fixed it
Expect(logs).To(ContainSubstring(`"/somethingOne"`)) | ||
}) | ||
|
||
It("should not logging access to default backend when it disabled", 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.
Please change the title to something like
disables access logging for default backend
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.
Thanks, I fixed it too
f.UpdateNginxConfigMapData("enable-access-log-for-default-backend", "true") | ||
host := "bar" | ||
resp, _, errs := gorequest.New(). | ||
Get(f.IngressController.HTTPURL+"/somethingTwo"). |
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 need to rebase with master and use the new API f.GetURL(framework.HTTP)
here instead of f.IngressController.HTTPURL
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.
Thanks, but I don't know because I get it error in previous time:
test/e2e/defaultbackend/default_backend.go:105:9: f.IngressController undefined (type *framework.Framework has no field or method IngressController)
f.UpdateNginxConfigMapData("enable-access-log-for-default-backend", "true") | ||
host := "foo" | ||
resp, _, errs := gorequest.New(). | ||
Get(f.IngressController.HTTPURL+"/somethingOne"). |
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.
/lgtm thanks @arturxx8 ! |
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.
fix e2e
|
||
logs, err := f.NginxLogs() | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(logs).To(ContainSubstring("/somethingOne")) |
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 I replace `"/somethingOne"` to "/somethingOne" because compare string looks like this:
10.244.2.1 - [10.244.2.1] - - [25/Feb/2019:21:04:21 +0000] "GET /somethingOne HTTP/1.1" 404 153 "-" "Go-http-client/1.1" 147 0.000 [upstream-default-backend] 127.0.0.1:8181 153 0.000 404 b7b4ad156e96a41d5543528f3bdc2ca6
|
||
logs, err := f.NginxLogs() | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(logs).ToNot(ContainSubstring("/somethingTwo")) |
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 i replace this same
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 was this line printed?
Is this a debug? I do not remember such lines in version 0.22.0
127.0.0.1 - [127.0.0.1] - - [25/Feb/2019:21:52:58 +0000] "GET /somethingTwo HTTP/1.1" 404 153 "-" "Go-http-client/1.1" 345 0.000 [internal] - - - - f31a446e7c617a1425739aa8adfa6c67
can you help me?
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.
@arturxx8 I think this is coming from the "upstream server":
# backend for when default-backend-service is not configured or it does not have endpoints |
I'm okay to solve this by adding access_log off;
in that server block.
disable log on default_server
@ElvinEfendi i fixed e2e tests. Could you add lgtm label back |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: arturxx8, 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:
Enable access log for default backend.
Without this PR, redirected URLs to the default backend are not logged.
https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/template/nginx.tmpl#L1107
on this line, the condition for the default backend is true, since the variable $location.Logs.Access does not exist
Which issue this PR fixes:
fixes #3603
Special notes for your reviewer: