-
Notifications
You must be signed in to change notification settings - Fork 7
Add log rotation scheduler job for the nginx logs #619
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
Changes from all commits
acda3ed
3f51a9f
3061518
0961f43
eeb9268
3ad5beb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 2.20.0 2025-12-10T22:06:17Z | ||
| 2.20.1 2025-12-16T18:09:59Z |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| config.yml | ||
| nginx.logrotate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| - name: logrotate-nginx | ||
| comment: Rotate log files for nginx | ||
| schedule: '${SCHEDULER_JOB_LOGROTATE_NGINX_JOB_SCHEDULE}' | ||
| command: bash -c 'cp /etc/logrotate.conf.orig /etc/logrotate.conf && chown root:root /etc/logrotate.conf && chmod 644 /etc/logrotate.conf && /usr/sbin/logrotate -v /etc/logrotate.conf' | ||
| dockerargs: >- | ||
| --rm --name logrotate-nginx | ||
| --volume ${COMPOSE_PROJECT_NAME}_proxy-logs:/var/log/nginx/:rw | ||
| --volume ${COMPOSE_DIR}/optional-components/scheduler-job-logrotate-nginx/nginx.logrotate:/etc/logrotate.conf.orig:ro | ||
| trigger: | ||
| - command: sh -c '[ -f /var/run/nginx.pid ] && kill -USR1 $(cat /var/run/nginx.pid)' | ||
| container: proxy | ||
| image: 'stakater/logrotate:3.13.0' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| services: | ||
| proxy: | ||
| volumes: | ||
| - proxy-logs:${PROXY_LOG_DIR} | ||
|
|
||
| volumes: | ||
| proxy-logs: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| services: | ||
| scheduler: | ||
| volumes: | ||
| - ./optional-components/scheduler-job-logrotate-nginx/config.yml:/scheduler-job-configs/logrotate-nginx.yml:ro |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| export SCHEDULER_JOB_LOGROTATE_NGINX_JOB_SCHEDULE="* * * * *" # UTC | ||
| export SCHEDULER_JOB_LOGROTATE_NGINX_ROTATE=150 | ||
| export SCHEDULER_JOB_LOGROTATE_NGINX_SIZE=1M | ||
|
|
||
| VARS=" | ||
| $VARS | ||
| \$SCHEDULER_JOB_LOGROTATE_NGINX_JOB_SCHEDULE | ||
| \$SCHEDULER_JOB_LOGROTATE_NGINX_ROTATE | ||
| \$SCHEDULER_JOB_LOGROTATE_NGINX_SIZE | ||
| " | ||
|
|
||
| # TODO: deprecate this component once https://github.com/bird-house/birdhouse-deploy/issues/618 is resolved | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a note to keep the |
||
| # remember that deprecating involves adding an entry to optional-components/.gitignore | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /var/log/nginx/${PROXY_LOG_FILE} { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just simply Not a blocking concern, I am just being curious.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure what other future files we should be considering here? Especially since we're planning on moving to logging to stdout and stderr only in the future.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes right now no other candidate to logrotate but I usually prefer to avoid locking myself and future proof myself (in general, I understand this case is special since it's a temporary fix), especially when it's very easy and there are no bad impact. So the reverse question is what mistake are we trying to prevent by locking this logrotate to one single file?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logrotate shows warnings when you tell it to rotate a stream. warnings warn us when we are doing something that the software doesn't like. I would prefer to not intentionally do something that raises warnings.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I do not meant to change the value of |
||
| missingok | ||
| # https://github.com/Ouranosinc/CanarieAPI/blob/cc0ae59231ee4b58a34571bd12097c660aefb2e3/canarieapi/logparser.py#L15 | ||
| rotate ${SCHEDULER_JOB_LOGROTATE_NGINX_ROTATE} | ||
| size ${SCHEDULER_JOB_LOGROTATE_NGINX_SIZE} | ||
| compress | ||
| delaycompress | ||
| notifempty | ||
| # log files in the proxy container are owned by root currently | ||
| create 640 root root | ||
| } | ||
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.
It's not just a large size it's also the hogging of CPU and RAM to parse that gigantic large log file on restart.
Since it's a regression, please also mention when the regression started "Broken since
2.3.0(#452)."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.
Sorry I wasn't clear, please also add the part about "hogging of CPU and RAM to parse that gigantic large log file on restart."