Skip to content

Commit c04a711

Browse files
danpawlikevallesp
authored andcommitted
Make static log dir for must-gather
In some cases, the os_must_gather role have an error: task path: /home/zuul/src/github.com/openstack-k8s-operators/ci-framework/roles/os_must_gather/tasks/main.yml:97 fatal: [localhost]: FAILED! => msg: | The task includes an option with an undefined variable. The error was: list object has no element 0. list object has no element 0 The error appears to be in '/home/zuul/src/github.com/openstack-k8s-operators/ci-framework/roles/os_must_gather/tasks/main.yml': line 97, column 7, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: Move must-gather folder name to a fixed name ^ here Print the _must_gather_output_folder folder name and run the move task if the path is available. We can drop making the folder name recognition and put the logs in static dir. Signed-off-by: Daniel Pawlik <[email protected]>
1 parent fe71df5 commit c04a711

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

roles/os_must_gather/tasks/main.yml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616

1717
- name: Ensure directories are present
1818
ansible.builtin.file:
19-
path: "{{ cifmw_os_must_gather_output_dir }}/{{ item }}"
19+
path: "{{ cifmw_os_must_gather_output_dir }}/logs/openstack-k8s-operators-openstack-must-gather"
2020
state: directory
2121
mode: "0755"
22-
loop:
23-
- logs
2422

2523
- name: Construct project change list
2624
ansible.builtin.set_fact:
@@ -65,40 +63,12 @@
6563
oc adm must-gather --image {{ cifmw_os_must_gather_image }}
6664
--timeout {{ cifmw_os_must_gather_timeout }}
6765
--host-network={{ cifmw_os_must_gather_host_network }}
68-
--dest-dir {{ cifmw_os_must_gather_output_dir }}/logs
66+
--dest-dir {{ cifmw_os_must_gather_output_dir }}/logs/openstack-k8s-operators-openstack-must-gather
6967
-- ADDITIONAL_NAMESPACES={{ cifmw_os_must_gather_additional_namespaces }}
7068
OPENSTACK_DATABASES=$OPENSTACK_DATABASES
7169
SOS_EDPM=$SOS_EDPM
7270
SOS_DECOMPRESS=$SOS_DECOMPRESS
73-
gather &> {{ cifmw_os_must_gather_output_dir }}/logs/os_must_gather.log
74-
75-
# directory name will be generated starting from cifmw_os_must_gather_image
76-
# variable e.g.:
77-
# EXAMPLE 1
78-
# original value: "quay.io/openstack-k8s-operators/openstack-must-gather:latest"
79-
# pattern value: "quay-io-openstack-k8s-operators-openstack-must-gather*"
80-
# EXAMPLE 2
81-
# original value: "foo.bar.example.com/repofoo/openstack-must-gather-rhel9:1.0.0"
82-
# patterns value: "foo-bar-example-com-repofoo-openstack-must-gather-rhel9*"
83-
# TODO: add molecule testing
84-
- name: Get exact must-gather output folder name
85-
ansible.builtin.find:
86-
paths: "{{ cifmw_os_must_gather_output_dir }}/logs"
87-
patterns: >-
88-
{{
89-
cifmw_os_must_gather_image |
90-
ansible.builtin.split(':') |
91-
first |
92-
ansible.builtin.regex_replace('([.]|[/])', '-') ~ '*'
93-
}}
94-
file_type: directory
95-
register: _must_gather_output_folder
96-
97-
- name: Move must-gather folder name to a fixed name
98-
ansible.builtin.command:
99-
cmd: >
100-
mv "{{ _must_gather_output_folder.files[0].path }}/"
101-
"{{ cifmw_os_must_gather_output_dir }}/logs/openstack-k8s-operators-openstack-must-gather"
71+
gather &> {{ cifmw_os_must_gather_output_dir }}/logs/openstack-k8s-operators-openstack-must-gather/os_must_gather.log
10272
10373
rescue:
10474
- name: Openstack-must-gather failure

0 commit comments

Comments
 (0)