Skip to content

Commit

Permalink
Fix convert_and_restore_config_db_to_ipv6_only reload config failure (#…
Browse files Browse the repository at this point in the history
…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: [email protected]
  • Loading branch information
liuh-80 authored Jun 14, 2024
1 parent ca453cd commit 8ca933e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/common/fixtures/duthost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8ca933e

Please sign in to comment.