syslog/messages/kern.log rollover not working on aks nodes
What happened: syslog/messages/kern.log rollover not working on aks linux nodes. Details of the issue here. https://docs.microsoft.com/en-us/answers/questions/244101/syslogmessageskernlog-rollover-not-working-on-aks.html
What you expected to happen: Roll-over should work
Resolution The issue is related to the OMS agent bug, which is hot-fixed for next week OMS agent update where we are removing log rotation settings in containers. In the meanwhile here is the short term solution you can use. The customer can download the logrotate-mitigation.sh file I have attached to the incident. In the same directory as the downloaded logrotate-mitigation.sh and with the kubectl context pointing to the correct cluster, run the following (I have also attached this as a file called all-omsagent-logrotate-mitigation.sh):
for pod in $(kubectl -n kube-system get pods --output=jsonpath={.items..metadata.name}); do
if [[ $pod == omsagent-* ]] && [[ $pod != omsagent-win-* ]]; then
kubectl cp -n kube-system logrotate-mitigation.sh $pod:/opt/logrotate-mitigation.sh
kubectl exec -it $pod -n kube-system -- bash -c "chmod +x /opt/logrotate-mitigation.sh"
kubectl exec -it $pod -n kube-system -- bash -c "/opt/logrotate-mitigation.sh"
fi
done
This runs the script on every omsagent container. The next time the node tries to rotate the files, there won't be a conflict with the container settings and it will start working again. The script works as follows:
# Remove logrotate settings for the container that overlap with node logrotate settings
# These are included in etc/logrotate.conf that the etc/cron.daily uses for the logrotate command
rm /etc/logrotate.d/alternatives /etc/logrotate.d/apt /etc/logrotate.d/rsyslog
# Move *.1 file so that logrotation can start again correctly the next time the node rotates the files
if [ -s /var/log/syslog.1 ] && [ ! -s /var/log/syslog ]; then
mv /var/log/syslog.1 /var/log/syslog
fi
if [ -s /var/log/kern.log.1 ] && [ ! -s /var/log/kern.log ]; then
mv /var/log/kern.log.1 /var/log/kern.log
fi
if [ -s /var/log/messages.1 ] && [ ! -s /var/log/messages ]; then
mv /var/log/messages.1 /var/log/messages
fi
However, until the release with the actual fix goes out, the script would need to be run again for that pod if the container restarts.
Also note that this will only fix the file rotation and the large file for syslog won't be removed for 7 days (and kern.log and messages for 4 days) based on the rotation settings (rotates daily and keeps 7 or 4 files). If the customer would like to delete the large file, they should only do so after it has been rotated correctly (after the script is run and after the node rotates the files, which it does once a day).
@vishiy, @saaror would you be able to assist?
Issue Details
What happened: syslog/messages/kern.log rollover not working on aks linux nodes. Details of the issue here. https://docs.microsoft.com/en-us/answers/questions/244101/syslogmessageskernlog-rollover-not-working-on-aks.html
What you expected to happen: Roll-over should work
Resolution The issue is related to the OMS agent bug, which is hot-fixed for next week OMS agent update where we are removing log rotation settings in containers. In the meanwhile here is the short term solution you can use. The customer can download the logrotate-mitigation.sh file I have attached to the incident. In the same directory as the downloaded logrotate-mitigation.sh and with the kubectl context pointing to the correct cluster, run the following (I have also attached this as a file called all-omsagent-logrotate-mitigation.sh):
for pod in $(kubectl -n kube-system get pods --output=jsonpath={.items..metadata.name}); do if [[ $pod == omsagent-* ]] && [[ $pod != omsagent-win-* ]]; then
kubectl cp -n kube-system logrotate-mitigation.sh $pod:/opt/logrotate-mitigation.sh
kubectl exec -it $pod -n kube-system -- bash -c "chmod +x /opt/logrotate-mitigation.sh"
kubectl exec -it $pod -n kube-system -- bash -c "/opt/logrotate-mitigation.sh"
fi
done
This runs the script on every omsagent container. The next time the node tries to rotate the files, there won't be a conflict with the container settings and it will start working again. The script works as follows:
Remove logrotate settings for the container that overlap with node logrotate settings
These are included in etc/logrotate.conf that the etc/cron.daily uses for the logrotate command
rm /etc/logrotate.d/alternatives /etc/logrotate.d/apt /etc/logrotate.d/rsyslog
Move *.1 file so that logrotation can start again correctly the next time the node rotates the files
if [ -s /var/log/syslog.1 ] && [ ! -s /var/log/syslog ]; then mv /var/log/syslog.1 /var/log/syslog fi if [ -s /var/log/kern.log.1 ] && [ ! -s /var/log/kern.log ]; then mv /var/log/kern.log.1 /var/log/kern.log fi if [ -s /var/log/messages.1 ] && [ ! -s /var/log/messages ]; then mv /var/log/messages.1 /var/log/messages fi
However, until the release with the actual fix goes out, the script would need to be run again for that pod if the container restarts.
Also note that this will only fix the file rotation and the large file for syslog won't be removed for 7 days (and kern.log and messages for 4 days) based on the rotation settings (rotates daily and keeps 7 or 4 files). If the customer would like to delete the large file, they should only do so after it has been rotated correctly (after the script is run and after the node rotates the files, which it does once a day).
Anything else we need to know?:
| Author: | saaror |
|---|---|
| Assignees: | saaror |
| Labels: |
|
| Milestone: | - |
Hey, just wondering if there is an update on this. I am seeing pod evictions from disk pressure due to very large log files in "/var/log", (>50GB). Has the fix already been deployed and if so will we need to restart nodes or take other action before we see the effects?
Also, just to confirm @saaror, does that second code snippet show the contents of logrotate-mitigation.sh? Or is that script available somewhere else?
@MaxTaggart Yes, the second code snippet is the content of lograte-mitigation.sh.
The fix will roll-out as part of next week train.
No restart is needed either, but you will need to still run the if statements part of the script if the node is already in the bad state.
Hi, yesterday had to clean about 90GB of log off our AKS node, because pods where evicted due to disk pressure. I'd like to prevent similar situations in the future. However for me it the state of this issue is not clear.
The fix will roll-out as part of next week train.
@saaror Was this fix already released? If so where can I find further information like patch notes for the release?
No restart is needed either, but you will need to still run the if statements part of the script if the node is already in the bad state.
Does "running the if statement part" mean to move the *.1 files? E.g. moving /var/log/syslog.1 to /var/log/syslog.
Hello, I am being affected by this issue and would appreciate an update
Hi @danielsimpson, we opened a support request in our Azure account and the support agent told us, that the fix should be released on 2020-07-02 for the West Europe region.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
This is already resolved. Closing the issue. Feel free to open if you still see the issue.