Skip to content

Commit

Permalink
Merge pull request #457 from ci-framework/log_gathering
Browse files Browse the repository at this point in the history
Run os_must_gather only in case of failure
  • Loading branch information
openshift-merge-robot authored Aug 24, 2023
2 parents 04e1b6d + 26b66db commit 54d80e3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
4 changes: 0 additions & 4 deletions ci_framework/playbooks/99-logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
ansible.builtin.import_role:
name: artifacts

- name: Run os_must_gather
ansible.builtin.import_role:
name: os_must_gather

- name: Ensure ansible.log is at the expected location
register: ansible_log_state
ansible.builtin.stat:
Expand Down
1 change: 1 addition & 0 deletions ci_framework/roles/artifacts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ None - writes happen only in the user home.
* `cifmw_artifacts_crc_host`: (String) Hostname of the CRC instance. Defaults to `api.crc.testing`.
* `cifmw_artifacts_crc_user`: (String) Username to connect to the CRC instance. Defaults to `core`.
* `cifmw_artifacts_crc_sshkey`: (String) Path to the private SSH key to connect to CRC. Defaults to `~/.crc/machines/crc/id_ecdsa`.
* `cifmw_artifacts_gather_logs`: (Boolean) Force gathering of logs, even in the case of successful test run. Defaults to `false`

## Examples
Usually we'll import the role as-is at the very start of the playbook, and
Expand Down
1 change: 1 addition & 0 deletions ci_framework/roles/artifacts/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ cifmw_artifacts_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-fra
cifmw_artifacts_crc_host: "api.crc.testing"
cifmw_artifacts_crc_user: "core"
cifmw_artifacts_crc_sshkey: "~/.crc/machines/crc/id_ecdsa"
cifmw_artifacts_gather_logs: "false"
22 changes: 17 additions & 5 deletions ci_framework/roles/artifacts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.

- name: Verify if "success" flag exists after successful tests execution
register: cifmw_success_flag
ansible.builtin.stat:
path: "{{ ansible_user_dir }}/cifmw-success"

- name: Ensure we have at least minimal ansible facts
tags:
- always
Expand Down Expand Up @@ -44,8 +49,15 @@
- always
ansible.builtin.import_tasks: cleanup.yml

- name: Gather CRC logs
ansible.builtin.import_tasks: crc.yml

- name: Gather EDPM logs
ansible.builtin.import_tasks: edpm.yml
- name: Gather logs when forced or tests failed
when: cifmw_artifacts_gather_logs | bool or not cifmw_success_flag.stat.exists
block:
- name: Run os_must_gather
ansible.builtin.import_role:
name: os_must_gather
rescue:
- name: Get CRC logs if os_must_gather failed
ansible.builtin.import_tasks: crc.yml
always:
- name: Get EDPM logs
ansible.builtin.import_tasks: edpm.yml
16 changes: 16 additions & 0 deletions deploy-edpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
# openstack-k8s-operators/install_yaml repository in order to leverage its
# own methods.

- name: Remove status flag
hosts: "{{ cifmw_target_host | default('localhost') }}"
tasks:
- name: Delete success flag if exists
ansible.builtin.file:
path: "{{ ansible_user_dir }}/cifmw-success"
state: absent

- name: Bootstrap step
ansible.builtin.import_playbook: ci_framework/playbooks/01-bootstrap.yml

Expand All @@ -31,6 +39,14 @@
ansible.builtin.import_playbook: ci_framework/playbooks/08-run-tests.yml
when: cifmw_run_tests | default('false') | bool

- name: Inject status flag
hosts: "{{ cifmw_target_host | default('localhost') }}"
tasks:
- name: Inject success flag
ansible.builtin.file:
path: "{{ ansible_user_dir }}/cifmw-success"
state: touch

- name: Run log related tasks
ansible.builtin.import_playbook: ci_framework/playbooks/99-logs.yml
when: not zuul_log_collection | default ('false') | bool

0 comments on commit 54d80e3

Please sign in to comment.