From 3d97eb0c40a96f5bbd5333aeda6105bd8735993c Mon Sep 17 00:00:00 2001 From: jgilaber Date: Mon, 13 May 2024 13:36:21 +0200 Subject: [PATCH] Reload crc NetworkManager in reproducer 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] https://github.com/openstack-k8s-operators/ci-framework/pull/1637 --- roles/reproducer/tasks/configure_crc.yml | 45 ++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/roles/reproducer/tasks/configure_crc.yml b/roles/reproducer/tasks/configure_crc.yml index 1895952d03..fc32628794 100644 --- a/roles/reproducer/tasks/configure_crc.yml +++ b/roles/reproducer/tasks/configure_crc.yml @@ -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: @@ -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