Skip to content

Commit

Permalink
Avoid failures on cleaning
Browse files Browse the repository at this point in the history
While working on integrating dnsmasq role in the reproducer, a random
issue, related to the facts, might happen.

It seems to be caused by the way ansible manages the handler - the
`ansible_facts.packages` isn't available anymore, and the condition
triggering the libvirt cleanup fails. While it was already done.

This condition arrises when dnsmasq role is in the game, and the handler
kicks at the end of the playbook.

In the same fashion, the handler might be triggered when the service is
already removed, leading to another crash of the cleanup playbook. The
added conditions ensure the handler will succeed even if the service is
already removed, but would still fail if there's a real issue with the
service configuration.
  • Loading branch information
cjeanner authored and openshift-merge-bot[bot] committed May 25, 2024
1 parent 75c6ef4 commit e5f9d1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions roles/dnsmasq/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

- name: Restart dnsmasq
become: true
register: _dnsmasq
ansible.builtin.systemd_service:
name: cifmw-dnsmasq.service
state: restarted
failed_when:
- _dnsmasq.msg is defined
- _dnsmasq.msg is not
match('Could not find the requested service cifmw-dnsmasq.service')
10 changes: 6 additions & 4 deletions roles/libvirt_manager/tasks/clean_layout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
ansible.builtin.package_facts: {}

- name: Perform the libvirt cleanup
when: >-
cifmw_libvirt_manager_dependency_packages |
difference(ansible_facts.packages.keys()) |
length == 0
when:
- ansible_facts.packages is defined
- >-
cifmw_libvirt_manager_dependency_packages |
difference(ansible_facts.packages.keys()) |
length == 0
block:
- name: List all of the existing virtual machines
register: vms_list
Expand Down

0 comments on commit e5f9d1d

Please sign in to comment.