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

Make access_log in http context configurable #5648

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

hafe
Copy link
Contributor

@hafe hafe commented May 29, 2024

Closes #5625

Proposed changes

See #5625

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@hafe hafe requested review from a team as code owners May 29, 2024 15:55
Copy link

netlify bot commented May 29, 2024

👷 Deploy request for nginx-kubernetes-ingress pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8de4bf3022281a4354ccb2688b2053b9f340d441

@github-actions github-actions bot added enhancement Pull requests for new features/feature enhancements documentation Pull requests/issues for documentation go Pull requests that update Go code labels May 29, 2024
Copy link
Contributor

@ADubhlaoich ADubhlaoich left a comment

Choose a reason for hiding this comment

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

Doc change LGTM!

@jjngx
Copy link
Contributor

jjngx commented Jun 17, 2024

Hi @hafe , could you please update the conflicting files?

@jjngx jjngx added the backlog Pull requests/issues that are backlog items label Jun 17, 2024
@jjngx jjngx added this to the v3.7.0 milestone Jun 17, 2024
@jjngx
Copy link
Contributor

jjngx commented Jun 21, 2024

@hafe , could you please gofumpt files that are failing validation

@hafe hafe force-pushed the feat/access-log-5625 branch 2 times, most recently from d595b46 to 12d31cb Compare June 22, 2024 06:43
@j1m-ryan
Copy link
Member

Thanks for the pr @hafe, @vepatel is looking at this pr now.

@jjngx
Copy link
Contributor

jjngx commented Aug 8, 2024

@hafe could you please update the branch? I am reviewing changes atm.

@jjngx jjngx self-assigned this Aug 8, 2024
@hafe
Copy link
Contributor Author

hafe commented Aug 8, 2024

@hafe could you please update the branch? I am reviewing changes atm.

You mean just rebase it from main?

@jjngx
Copy link
Contributor

jjngx commented Aug 8, 2024

@hafe could you please update the branch? I am reviewing changes atm.

You mean just rebase it from main?

Yes, please rebase.

@jjngx
Copy link
Contributor

jjngx commented Aug 9, 2024

@hafe thank you again for contributing. I've tested the feature and confirm it works as expected.

input data:

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
  namespace: nginx-ingress
data:
  access-log: "yslog:server=localhost:514"
  access-log-off: "false"

will results with: access_log /dev/stdout main;

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
  namespace: nginx-ingress
data:
  access-log: "syslog:server=localhost:514"
  access-log-off: "false"

will results with: access_log syslog:server=localhost:514;

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
  namespace: nginx-ingress
data:
  access-log: "syslog:server=localhost:514"
  access-log-off: "true"

will result with: access_log off;

If a user tries to set a value that is not valid, the log will be set to default one. NIC logs will show the error:

E20240809 10:59:06.679467       1 configmaps.go:212] Configmap nginx-ingress/nginx-config: Invalid value for key access-log: "ssyslog:server=localhost:514"

@hafe since the NIC does not handle warnings in case of invalid access_log value, could you please add information to the error log to inform user that the access_log value will be set to default (/dev/stdout main)?

Handling the error event will likely be a separate PR.

cc / @vepatel @shaun-nx

@hafe
Copy link
Contributor Author

hafe commented Aug 9, 2024

I can do that. It should really be a warning log also

@vepatel
Copy link
Contributor

vepatel commented Aug 9, 2024

@jjngx @hafe lets add it to the docs as well for clarity and since we can't report it through configmap event:

access_log value will be set to /dev/stdout main in-case user tries to configure it with location other than a syslog.

@jjngx
Copy link
Contributor

jjngx commented Aug 9, 2024

@hafe could you please also update template tests?

@hafe
Copy link
Contributor Author

hafe commented Aug 9, 2024

Not sure what you mean by that

@jjngx
Copy link
Contributor

jjngx commented Aug 9, 2024

Not sure what you mean by that

could you run make test from the root dir of the project and check if the internal/configs/version1/__snapshots__/template_test.snap changes? When you look in the file there are new lines: access_log ; that indicates invalid (from NGINX perspective) lines.

@hafe
Copy link
Contributor Author

hafe commented Aug 9, 2024

No nothing changes.

@jjngx
Copy link
Contributor

jjngx commented Aug 9, 2024

No nothing changes.

Ok, I will check what is going on with the templates and snapshots, and get back to you ASAP.

@jjngx
Copy link
Contributor

jjngx commented Aug 9, 2024

No nothing changes.

Ok, I will check what is going on with the templates and snapshots, and get back to you ASAP.

@hafe there is a missing filed AccessLog in multiple input data (config structs) in the template_test.go file in pkg internal/configs/version1. Please note that after the access_log change the MainConfig struct requires the AccessLog value to be defined, for example: AccessLog: "/dev/stdout main", as you added on line 2041.
You need to update all structs (MainConfig) that are used as input test data for all template tests. After that please run make test and check if the test template is updated.

After that please update the branch. Once again thank you for contributing! I am hoping to get your PR merged next week.

Closes nginxinc#5625

Signed-off-by: Hans Feldt <2808287+hafe@users.noreply.github.com>
@hafe
Copy link
Contributor Author

hafe commented Aug 9, 2024

Seems to be OK now after latest updates. Thanks for the help!

Copy link
Contributor

@jjngx jjngx left a comment

Choose a reason for hiding this comment

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

👍🏻

@jjngx jjngx merged commit 9eeebc9 into nginxinc:main Aug 12, 2024
132 of 149 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Pull requests/issues that are backlog items documentation Pull requests/issues for documentation enhancement Pull requests for new features/feature enhancements go Pull requests that update Go code
Projects
Status: Done 🚀
Development

Successfully merging this pull request may close these issues.

Make access_log for main configurable
5 participants