Skip to content

Commit

Permalink
Reload crc NetworkManager in reproducer
Browse files Browse the repository at this point in the history
The fix for reproducer dns[1] does not seem to work in all instances.
NetworkManager was still overwriting the /etc/resolv.conf contents, so
this change reloads the service after changing the config to ensure it
does not modify the resolv.conf on reboot. Additionally, instead of
rebooting, restart the dnsmasq service.

[1] #1637
  • Loading branch information
cescgina committed May 13, 2024
1 parent d004459 commit 3d97eb0
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions roles/reproducer/tasks/configure_crc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
# Managed by ansible/cifmw
nameserver {{ _crc.ip_v4 }}
- name: Reload NetworkManager to ensure it read the conf changes
become: true
ansible.builtin.service:
name: NetworkManager
state: "reloaded"

- name: Check which dnsmasq config we must edit
register: _dnsmasq
ansible.builtin.stat:
Expand Down Expand Up @@ -84,9 +90,44 @@
regexp: "listen-address={{ _crc.ip_v4 }}"
replace: "listen-address={{ _crc.ip_v4 }},127.0.0.1"

- name: Reboot CRC node
- name: Restart dnsmasq service when available
when: not _dnsmasq.stat.exists
become: true
ansible.builtin.reboot:
ansible.builtin.service:
name: dnsmasq
state: "restarted"

- name: Restart dnsmasq container for older crc versions
when: _dnsmasq.stat.exists
become: true
block:
# taken from
# https://github.com/openstack-k8s-operators/ci-framework/blob/73e5170693c18f5d244c91f83ad240f6804cbec9/ci/playbooks/multinode-customizations.yml#L111
# Avoid 'state: restarted' due to issues with IP not
# available when crc-dnsmasq starts
- name: Stop dnsmasq
become: true
ansible.builtin.systemd:
state: stopped
name: crc-dnsmasq

- name: Make sure that crc-dnsmasq is not running
containers.podman.podman_container:
name: crc-dnsmasq
state: absent

- name: Start dnsmasq
become: true
ansible.builtin.systemd:
state: started
name: crc-dnsmasq
register: _dnsmasq_start_reg
retries: 15
delay: 20
until:
- _dnsmasq_start_reg.failed is false
- _dnsmasq_start_reg.status is defined
- _dnsmasq_start_reg.status.ActiveState == "active"

- name: Ensure hypervisor has the right CRC IP
become: true
Expand Down

0 comments on commit 3d97eb0

Please sign in to comment.