From ae9f212086b9a91a5f96654613d56d5b8bf43bef Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Wed, 31 Jan 2024 14:39:49 -0500 Subject: [PATCH] test: Retry until success when installing package Sometimes the rpm download returns a 403, which is likely caused by too many parallel jobs attempt the download from the same controller in too short a period of time, so the epel server throttles additional downloads - use a retry here to mitigate. Signed-off-by: Wen Liang --- tasks/main.yml | 3 +++ tests/playbooks/tests_bond_deprecated.yml | 10 ++++++++++ tests/tasks/create_test_interfaces_with_dhcp.yml | 8 ++++++++ tests/tasks/manage_test_interface.yml | 4 ++++ tests/tasks/setup_802_1x_server.yml | 4 ++++ tests/tasks/setup_mock_wifi.yml | 4 ++++ tests/tasks/setup_mock_wifi_wpa3_owe.yml | 4 ++++ tests/tasks/setup_mock_wifi_wpa3_sae.yml | 8 ++++++++ 8 files changed, 45 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 4deb3a0..c55f5ef 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -36,6 +36,9 @@ when: - not network_packages is subset(ansible_facts.packages.keys()) register: __network_package_install + until: __network_package_install is success + retries: 6 + delay: 10 - name: Install NetworkManager and nmstate when using network_state variable package: diff --git a/tests/playbooks/tests_bond_deprecated.yml b/tests/playbooks/tests_bond_deprecated.yml index 572bf8a..446dc89 100644 --- a/tests/playbooks/tests_bond_deprecated.yml +++ b/tests/playbooks/tests_bond_deprecated.yml @@ -23,6 +23,11 @@ import_tasks: tasks/assert_device_present.yml vars: interface: "{{ dhcp_interface2 }}" + - name: "Backup the /etc/resolv.conf for initscript" + command: cp -vf /etc/resolv.conf /etc/resolv.conf.bak + when: + - network_provider == "initscripts" + changed_when: false - name: Test bond device using deprecated 'master' argument block: - name: "TEST Add Bond with 2 ports using deprecated 'master' argument" @@ -113,3 +118,8 @@ changed_when: false - name: Import the task 'remove_test_interfaces_with_dhcp.yml' import_tasks: tasks/remove_test_interfaces_with_dhcp.yml + - name: "Restore the /etc/resolv.conf for initscript" + command: mv -vf /etc/resolv.conf.bak /etc/resolv.conf + when: + - network_provider == "initscripts" + changed_when: false diff --git a/tests/tasks/create_test_interfaces_with_dhcp.yml b/tests/tasks/create_test_interfaces_with_dhcp.yml index 98f5061..1c42c34 100644 --- a/tests/tasks/create_test_interfaces_with_dhcp.yml +++ b/tests/tasks/create_test_interfaces_with_dhcp.yml @@ -6,6 +6,14 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + # sometimes the rpm download returns a 403 - I think it is when too + # many parallel jobs attempt the download from the same controller in + # too short a period of time, so the epel server throttles additional + # downloads - use a retry here to mitigate + until: __install_status is success + retries: 6 + delay: 10 - name: Install pgrep, sysctl package: diff --git a/tests/tasks/manage_test_interface.yml b/tests/tasks/manage_test_interface.yml index e4352e8..c05ef82 100644 --- a/tests/tasks/manage_test_interface.yml +++ b/tests/tasks/manage_test_interface.yml @@ -19,6 +19,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 # veth - name: Create veth interface {{ interface }} diff --git a/tests/tasks/setup_802_1x_server.yml b/tests/tasks/setup_802_1x_server.yml index a994965..0041a5a 100644 --- a/tests/tasks/setup_802_1x_server.yml +++ b/tests/tasks/setup_802_1x_server.yml @@ -19,6 +19,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Create directory for test certificates file: diff --git a/tests/tasks/setup_mock_wifi.yml b/tests/tasks/setup_mock_wifi.yml index e8d7abc..94a19f7 100644 --- a/tests/tasks/setup_mock_wifi.yml +++ b/tests/tasks/setup_mock_wifi.yml @@ -9,6 +9,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Ensure NetworkManager is running service: diff --git a/tests/tasks/setup_mock_wifi_wpa3_owe.yml b/tests/tasks/setup_mock_wifi_wpa3_owe.yml index cba987f..5d8048d 100644 --- a/tests/tasks/setup_mock_wifi_wpa3_owe.yml +++ b/tests/tasks/setup_mock_wifi_wpa3_owe.yml @@ -8,6 +8,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Check if can test on CentOS and setup if possible when: ansible_distribution == 'CentOS' diff --git a/tests/tasks/setup_mock_wifi_wpa3_sae.yml b/tests/tasks/setup_mock_wifi_wpa3_sae.yml index 00418cd..94078e6 100644 --- a/tests/tasks/setup_mock_wifi_wpa3_sae.yml +++ b/tests/tasks/setup_mock_wifi_wpa3_sae.yml @@ -8,6 +8,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Configure CentOS system for testing, if possible when: ansible_distribution == 'CentOS' @@ -42,6 +46,10 @@ state: present when: - ansible_distribution == 'Fedora' + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 # Since DNF package manager can not warrant installing the kernel module with # the same version as the kernel in target machine, install the kernel module