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

Enable access log for default backend #3780

Merged
merged 1 commit into from
Feb 26, 2019
Merged

Enable access log for default backend #3780

merged 1 commit into from
Feb 26, 2019

Conversation

mymarche
Copy link

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:

@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 19, 2019
@codecov-io
Copy link

Codecov Report

Merging #3780 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43cfbb9...afc4784. Read the comment docs.

@mymarche
Copy link
Author

@aledbf Could you approve this PR? Without it very difficult to debug incoming requests to the ingress controller.

@aledbf
Copy link
Member

aledbf commented Feb 22, 2019

@arturxx8 please add at least one e2e test (checking the log contains information about the request) and also squash the commits

@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 25, 2019
@aledbf
Copy link
Member

aledbf commented Feb 25, 2019

@arturxx8 please sign the CLA and squash the commits

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 25, 2019
})

It("should not logging access to default backend when it disabled", func() {
f.UpdateNginxConfigMapData("enable-access-log-for-default-backend", "true")
Copy link
Member

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?

Copy link
Author

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"`))
Copy link
Member

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

Copy link
Author

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() {
Copy link
Member

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

Copy link
Author

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() {
Copy link
Member

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

Copy link
Author

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").
Copy link
Member

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

Copy link
Author

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").
Copy link
Member

Choose a reason for hiding this comment

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

@ElvinEfendi
Copy link
Member

/lgtm
/approve

thanks @arturxx8 !

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Feb 25, 2019
Copy link
Author

@mymarche mymarche left a 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"))
Copy link
Author

@mymarche mymarche Feb 25, 2019

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"))
Copy link
Author

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

Copy link
Author

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?

Copy link
Member

@ElvinEfendi ElvinEfendi Feb 25, 2019

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
. That's the upstream used when there's no custom default backend configured.

I'm okay to solve this by adding access_log off; in that server block.

disable log on default_server
@mymarche
Copy link
Author

@ElvinEfendi i fixed e2e tests. Could you add lgtm label back

@ElvinEfendi
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to get which url redirect to default backend
5 participants