fix(logrotate): rotate the php-fpm slowlog and let stanzas be added - #79
Merged
zebby76 merged 1 commit intoSep 7, 2026
Conversation
PHP_FPM_SLOWLOG defaulted to /app/var/log/php-fpm.log.slow, which the rotation glob /app/var/log/*.log does not match. Asked what it would act on, logrotate listed app.log and supervisord.log and never the slowlog: a deployment that turned the slowlog on grew one unbounded file on the very volume every other log was being rotated on, and on an emptyDir that ends in an evicted pod. The name now ends in .log. The knob is still there for anyone whose collector targets the old path by name. The slowlog is off by default (request_slowlog_timeout is 0), which is why this went unnoticed: the file only appears once an operator turns it on, and that is exactly the operator who then loses the volume. Second, the README described adding a stanza of your own, and nothing rendered one. logrotate.conf is an `include /opt/etc/logrotate.d`, so it was possible in principle, but base.d/70-logrotate.sh only ever wrote default.conf. Every .tmpl in /opt/config/logrotate/logrotate.d is rendered now, the way /opt/config/sbin already works, and the options datasource is passed to each one so a stanza can reuse LOGROTATE_DEFAULT_OPTIONS rather than restate the policy. The documentation gains the two things an operator has to plan for and could not read anywhere: copytruncate loses the lines written between the copy and the truncation, and a rotation transiently holds the live file, its copy and the compressed output at once. With the defaults that is roughly 350 MB for /app/var/log/*.log, which is the number that decides an emptyDir size. Also here, a defect the demo stacks caught and the image suites could not: three assertions in demo-prime still checked that /real-time-status, /status and /server-status answered 200 *through Varnish*. Varnish fronts the application port, so they were asserting the exposure Smals-Webtech#77 closed. The same three were inverted on 8.4 while resolving that backport's conflict, and missed here -- they query :6081, and the edit that moved the others matched :9000 only. They assert 404 now, on both branches.
zebby76
added a commit
that referenced
this pull request
Sep 7, 2026
…backport of #79 to 8.4) (#80) PHP_FPM_SLOWLOG defaulted to /app/var/log/php-fpm.log.slow, which the rotation glob /app/var/log/*.log does not match. Asked what it would act on, logrotate listed app.log and supervisord.log and never the slowlog: a deployment that turned the slowlog on grew one unbounded file on the very volume every other log was being rotated on, and on an emptyDir that ends in an evicted pod. The name now ends in .log. The knob is still there for anyone whose collector targets the old path by name. The slowlog is off by default (request_slowlog_timeout is 0), which is why this went unnoticed: the file only appears once an operator turns it on, and that is exactly the operator who then loses the volume. Second, the README described adding a stanza of your own, and nothing rendered one. logrotate.conf is an `include /opt/etc/logrotate.d`, so it was possible in principle, but base.d/70-logrotate.sh only ever wrote default.conf. Every .tmpl in /opt/config/logrotate/logrotate.d is rendered now, the way /opt/config/sbin already works, and the options datasource is passed to each one so a stanza can reuse LOGROTATE_DEFAULT_OPTIONS rather than restate the policy. The documentation gains the two things an operator has to plan for and could not read anywhere: copytruncate loses the lines written between the copy and the truncation, and a rotation transiently holds the live file, its copy and the compressed output at once. With the defaults that is roughly 350 MB for /app/var/log/*.log, which is the number that decides an emptyDir size. Also here, a defect the demo stacks caught and the image suites could not: three assertions in demo-prime still checked that /real-time-status, /status and /server-status answered 200 *through Varnish*. Varnish fronts the application port, so they were asserting the exposure #77 closed. The same three were inverted on 8.4 while resolving that backport's conflict, and missed here -- they query :6081, and the edit that moved the others matched :9000 only. They assert 404 now, on both branches. (cherry picked from commit 114e2ea) The demo-prime conflict is the variable name again -- BATS_CONTAINER_NAME here, BATS_VARNISH_CONTAINER_NAME on main. The three via-Varnish assertions were already inverted on this branch while resolving #78, so only the name is kept from here and the 404s were identical on both sides.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the last defect of the analysis pass, and repairs one thing #77 left behind.
The slowlog was never rotated
PHP_FPM_SLOWLOGdefaulted to/app/var/log/php-fpm.log.slow, which the rotation glob/app/var/log/*.logdoes not match. Asked what it would act on, logrotate answered:Never the slowlog. A deployment that turned it on grew one unbounded file on the very volume every
other log was being rotated on — and on an
emptyDir, that ends in an evicted pod. After the renameto
php-fpm-slow.log:Worth noting why this went unnoticed: the slowlog is off by default
(
request_slowlog_timeoutis0), so the file only appears once an operator turns it on — and thatis precisely the operator who then loses the volume. The knob remains, for anyone whose collector
targets the old path by name.
Adding a stanza was documented but impossible
The README described per-file policies, and nothing rendered one.
logrotate.confis aninclude /opt/etc/logrotate.d, so it was possible in principle, butbase.d/70-logrotate.shonlyever wrote
default.conf.Every
.tmplin/opt/config/logrotate/logrotate.dis rendered now — the same extension point/opt/config/sbinalready offers — and theoptionsdatasource is passed to each, so a stanza canreuse
LOGROTATE_DEFAULT_OPTIONSinstead of restating the policy. Verified with a mounted template:Sizing, which an operator could not read anywhere
Two consequences of
copytruncateare now documented: it loses the lines written between the copyand the truncation, and a rotation transiently holds the live file, its copy and the compressed
output at once. With the defaults that is roughly 350 MB for
/app/var/log/*.log— the numberthat decides an
emptyDirsize.A defect the demo stacks caught and the image suites could not
Three assertions in
demo-primestill checked that/real-time-status,/statusand/server-statusanswered 200 through Varnish. Varnish fronts the application port, so they wereasserting the very exposure #77 closed.
The same three were inverted on
8.4while resolving that backport's conflict, and missed here —they query
:6081, and the edit that moved the others matched:9000only. The PR body of #78 saidthese assertions were specific to
8.4; that was wrong,mainhas them too. They assert404now,on both branches.
This is the argument for running the demo stacks before a release:
nginxandapachewere 48/48and could not see it, because Varnish exists only there.
Verification
Image suites on locally built images:
nginx48/48,apache48/48,cli8/8. Two new assertions,both failing against the published
8.5.9image.Demo stacks, with
demo-infraup:demo-origin19/19,demo-prime12/12,demo-symfony6/6.BASH_EXEC,BASH,SHELL_SHFMT,MARKDOWNandNATURAL_LANGUAGElinters clean.The php-fpm slowlog is written to
php-fpm-slow.loginstead ofphp-fpm.log.slow. A collectortargeting the old name has to follow, or set
PHP_FPM_SLOWLOGback.Backport to
8.4to follow.