-
Notifications
You must be signed in to change notification settings - Fork 99
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
Excessive Log File Accumulation in /var/log/kairos Due to Timestamp-Based Naming #3207
Comments
The file timestamping is happening here: https://github.com/kairos-io/kairos-sdk/blob/c52bfb57089d55ea3666b94747522a89941b481c/types/logger.go#L26 While I try to understand why we do that (and not just let logrotate rotate the thing), a workaround could be to implement manual cleanup by setting up a cron job that parses those files and cleans up old ones (that's what timestamps are there for right?). I'll play with this a bit to see if it could work. |
Actually, with the time format including milliseconds, it means we create a new file every time. We never re-use a file. Doesn't affect the above workaround, but I'm just pointing out that it's not a "rotation mechanism" implemented there. |
We could probably improve the situation if we didn't That's only if we really want to take care of rotation and timestamping. Currently I leaning towards appending always to the same file and letting logrotate do its magic. Question, do we have logrotate in all flavors? (e.g. alpine) |
kairos-io/kairos-sdk#566 from yesterday IIRC the timestamp was due to several processes writing to the same file and making it a mess to understand |
In the meantime, as a workaround, one could rely either on the file metadata to cleanup old files, or on the filename. Chatgpt quickly came up with this (working) script for cleanup:
A crontab entry like this:
will make sure it gets triggered every 5 minutes. |
on an already installed system, adding this in
|
We have observed that despite using maxage for log deletion, the issue persists because log files are generated every hour with unique timestamps. As a result, logrotate treats each file as a new log, and when a file is compressed and rotated, the original version remains. Hence, logrotate won't help much in rotating the old logs.
For ex: The log file which was part of 07th Feb log generation, is still available, as .log file will be the active file always. Refer the below screenshot.
Removing create or copytruncate may not be ideal, as it could impact the logging process. Given this, do we have any other recommendations to address this issue effectively?
Kairos version:
NAME="SLE Micro"
VERSION="5.4"
VERSION_ID="5.4"
PRETTY_NAME="SUSE Linux Enterprise Micro for Rancher 5.4"
ID="sle-micro-rancher"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sle-micro-rancher:5.4"
KAIROS_NAME="kairos-core-sles"
KAIROS_VERSION="v3.1.3"
KAIROS_ID="sles"
KAIROS_ID_LIKE="kairos-core-sles"
KAIROS_VERSION_ID="v3.1.3"
KAIROS_PRETTY_NAME="kairos-core-sles v3.1.3"
KAIROS_BUG_REPORT_URL="https://github.com/spectrocloud/CanvOS/issues"
KAIROS_HOME_URL="https://github.com/spectrocloud/CanvOS"
KAIROS_IMAGE_REPO="spectrocloud/CanvOS"
KAIROS_IMAGE_LABEL="latest"
KAIROS_GITHUB_REPO=""
KAIROS_VARIANT="sles"
KAIROS_FLAVOR="sles"
KAIROS_ARTIFACT="kairos-core-sles-v3.1.3"
CPU architecture, OS, and Version:
Linux edge-21f135429dda5453ed78724ee89aeedb 5.14.21-150500.55.59-default #1 SMP PREEMPT_DYNAMIC Thu Apr 18 12:59:33 UTC 2024 (e8ae24a) x86_64 x86_64 x86_64 GNU/Linux
Describe the bug
As the log file name used in the /var/log/kairos has the timestamps, hence the logrotate utility won't be helpful in rotating it. It would be better to have different way of naming it
To Reproduce
Take any old or 1 week old kairos based edge host. Monitor the /var/log/kairos folder
Expected behavior
Filenames should be such that it can be rotated
The text was updated successfully, but these errors were encountered: