Skip to content

Commit a57402f

Browse files
danpawliksdatko
authored andcommitted
Do not relay on cifmw_openshift_kubeconfig if set in os_must_gather
The variable cifmw_openshift_kubeconfig might not be set, but the file can exist. Try to check if the kubeconfig file exists, then trigger must-gather command. Signed-off-by: Daniel Pawlik <[email protected]>
1 parent 4fadc6b commit a57402f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

roles/os_must_gather/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ cifmw_os_must_gather_namespaces:
3737
- crc-storage
3838
cifmw_os_must_gather_host_network: false
3939
cifmw_os_must_gather_dump_db: "ALL"
40+
cifmw_os_must_gather_kubeconfig: "{{ ansible_user_dir }}/.kube/config"

roles/os_must_gather/tasks/main.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,20 @@
4444
register: oc_installed
4545
ignore_errors: true
4646

47+
- name: Check if kubeconfig exists
48+
ansible.builtin.stat:
49+
path: "{{ cifmw_openshift_kubeconfig | default(cifmw_os_must_gather_kubeconfig) }}"
50+
register: _kubeconfig_stat
51+
4752
- name: Running openstack-must-gather tool
4853
when:
4954
- oc_installed is defined
5055
- oc_installed.rc == 0
51-
- cifmw_openshift_kubeconfig is defined
56+
- _kubeconfig_stat.stat.exists
5257
block:
5358
- name: Run openstack-must-gather command
5459
environment:
55-
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
60+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig | default(cifmw_os_must_gather_kubeconfig) }}"
5661
PATH: "{{ cifmw_path }}"
5762
SOS_EDPM: "all"
5863
SOS_DECOMPRESS: "0"
@@ -93,7 +98,7 @@
9398

9499
- name: Run fallback generic must-gather command
95100
environment:
96-
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
101+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig | default(cifmw_os_must_gather_kubeconfig) }}"
97102
PATH: "{{ cifmw_path }}"
98103
ansible.builtin.command:
99104
cmd: oc adm must-gather --dest-dir {{ ansible_user_dir }}/ci-framework-data/must-gather
@@ -107,7 +112,7 @@
107112
- name: Inspect the cluster after must-gather failure
108113
ignore_errors: true # noqa: ignore-errors
109114
environment:
110-
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
115+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig | default(cifmw_os_must_gather_kubeconfig) }}"
111116
PATH: "{{ cifmw_path }}"
112117
cifmw.general.ci_script:
113118
output_dir: "{{ cifmw_os_must_gather_output_dir }}/artifacts"

0 commit comments

Comments
 (0)