resume logs if prerotate script fails#502
resume logs if prerotate script fails#502banjiuqingshan wants to merge 1 commit intologrotate:masterfrom
Conversation
logrotate.c
Outdated
| int numRotated = 0; | ||
| struct logState **state; | ||
| struct logNames **rotNames; | ||
| struct resumeConfigs *resCfgs; |
There was a problem hiding this comment.
The resumeConfigs struct can be allocated on the stack so that we do not need to handle its (de)allocation explicitly.
| int rotateCount = resCfgs->rotateCount; | ||
| int logStart = resCfgs->logStart; | ||
|
|
||
| if (asprintf(&oldName, "%s/%s.%d%s%s", rotNames->dirName, |
There was a problem hiding this comment.
The code that constructs oldname should be moved to a helper function so that it is maintained at a single place.
There was a problem hiding this comment.
This place can indeed be refined. we can optimize it next time because it is also used elsewhere
|
I have no strong opinion on the behavior: the prerotate script failing is an error case, in which logrotate exists with a non 0 exit value and thus the system administrator should be notified (either via cron sending an email or the systemd timer entering the failing state). The man page currently only states
and
so the whether old logs are rotated on failure is not (for me at least) clearly stated. Looking at the changed test cases isn't the change more about reverting the rotation of old logs than resuming? |
|
I mean that logs that have been rotated will be renamed and overwritten, similar to test.log.3.gz, which will be renamed to test.log.4.gz.The commit will rename test.log.4gz back to test.log.3gz if the prerotate execution fails.Please consider whether this is necessary |
Ensures old logs are preserved and not rotated out for logs with a failing prerotate script. Alternative to logrotate#502
|
This proposal does not resume/restore old logs of other files from the same directive when using |
|
Ensures old logs are preserved and not rotated out for logs with a failing prerotate script. Alternative to logrotate#502
Ensures old logs are preserved and not rotated out for logs with a failing prerotate script. Alternative to #502
|
Closing in favor of #506 (now merged). |
resume logs if prerotate script fails.#498