bugfix:TSG-14782:临时修复k3s不断产生Cleaned up orphaned pod volumes dir日志的错误

This commit is contained in:
fumingwei
2023-05-16 16:23:08 +08:00
parent a7551d1015
commit c051eccb36
3 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
#!/bin/bash
KUBELET_HOME=/var/lib
for ((i=1; i<=5; i++));
do
for podid in $(grep "orphaned pod" /var/log/messages | tail -1 | awk '{print $23}' | sed 's/\\\"//g');
do
echo $podid
if [ ! -d ${KUBELET_HOME}/kubelet/pods/$podid ]; then
break
fi
rm -rf ${KUBELET_HOME}/kubelet/pods/$podid/
#echo ${KUBELET_HOME}/kubelet/pods/$podid/
done
sleep 2
done

View File

@@ -0,0 +1 @@
0 * * * * /opt/tsg/k3s/scripts/clean_orphaned_pods_dir.sh

View File

@@ -54,3 +54,14 @@
copy:
src: "{{ role_path }}/files/config.yaml"
dest: /etc/rancher/k3s/
- name: "copy clean_orphaned_pods_dir to dest"
copy:
src: "{{ role_path }}/files/clean_orphaned_pods_dir.sh"
dest: /opt/tsg/k3s/scripts/
mode: 0755
- name: "copy crontab file to dest"
copy:
src: "{{ role_path }}/files/crontab_clean_orphaned_pods_dir"
dest: /var/spool/cron/root