From 40ac86871679ce449a295cfbc0e7a27cb48223ec Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:17:07 +0800 Subject: [PATCH] Fix convert_and_restore_config_db_to_ipv6_only reload config failure (#13277) Fix convert_and_restore_config_db_to_ipv6_only reload config failure. Why I did it convert_and_restore_config_db_to_ipv6_only fixture will delete ipv4 mgmt address by config reload. If mgmt interface restart before config reload, the duthost class will lost connection to device and throw unreachable exception. How I did it Ignore config reload AnsibleConnectionFailure exception. How to verify it Pass all test case. Description for the changelog Fix convert_and_restore_config_db_to_ipv6_only reload config failure. co-authorized by: jianquanye@microsoft.com --- tests/common/fixtures/duthost_utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/common/fixtures/duthost_utils.py b/tests/common/fixtures/duthost_utils.py index 3d8d9078eda..ee99527e222 100644 --- a/tests/common/fixtures/duthost_utils.py +++ b/tests/common/fixtures/duthost_utils.py @@ -9,6 +9,7 @@ import time import json +from ansible.errors import AnsibleConnectionFailure from paramiko.ssh_exception import AuthenticationException from tests.common import config_reload @@ -752,7 +753,13 @@ def convert_and_restore_config_db_to_ipv6_only(duthosts): for duthost in duthosts.nodes: if config_db_modified[duthost.hostname]: logger.info(f"config changed. Doing config reload for {duthost.hostname}") - config_reload(duthost, wait=120) + try: + config_reload(duthost, wait=120) + except AnsibleConnectionFailure as e: + # IPV4 mgmt interface been deleted by config reload + # In latest SONiC, config reload command will exit after mgmt interface restart + # Then 'duthost' will lost IPV4 connection and throw exception + logger.warning(f'Exception after config reload: {e}') duthosts.reset() for duthost in duthosts.nodes: