From 2788a0209663bf09667500a37a0bcf76a38f3588 Mon Sep 17 00:00:00 2001 From: Ho Kim Date: Thu, 9 Feb 2023 12:04:36 +0900 Subject: [PATCH] Fix a bug in removing kubelet data dir (#9764) --- roles/reset/tasks/main.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index 9af7f079d..2d41ec2a7 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -257,14 +257,23 @@ - enable_nodelocaldns|default(false)|bool - nodelocaldns_device.stat.exists -- name: reset | find files/dirs with immutable flag in /var/lib/kubelet +- name: reset | Check whether /var/lib/kubelet directory exists + stat: + path: /var/lib/kubelet + get_attributes: no + get_checksum: no + get_mime: no + register: var_lib_kubelet_directory + +- name: reset | Find files/dirs with immutable flag in /var/lib/kubelet command: lsattr -laR /var/lib/kubelet become: true register: var_lib_kubelet_files_dirs_w_attrs changed_when: false no_log: true + when: var_lib_kubelet_directory.stat.exists -- name: reset | remove immutable flag from files/dirs in /var/lib/kubelet +- name: reset | Remove immutable flag from files/dirs in /var/lib/kubelet file: path: "{{ filedir_path }}" state: touch @@ -275,6 +284,7 @@ label: "{{ filedir_path }}" vars: filedir_path: "{{ file_dir_line.split(' ')[0] }}" + when: var_lib_kubelet_directory.stat.exists - name: reset | delete some files and directories file: