Skip to content

Commit 32d7efb

Browse files
committed
Retry set|get_link_attribute(s) if the interface is not present
After some interface operations (in particular the ``IpLinkCommand.set_ns`` operation), the network interface is temporarily not present in the destination namespace. This patch retries the interface "ip link set|show" command in that case. Related-Bug: #1961740 Change-Id: I5a57cfc71ad59f1fe9ea65e19b1a32314d798729 (cherry picked from commit 016f518)
1 parent 85debdd commit 32d7efb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

neutron/privileged/agent/linux/ip_lib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ def set_link_flags(device, namespace, flags):
348348
_run_iproute_link("set", device, namespace, flags=new_flags)
349349

350350

351+
@tenacity.retry(
352+
retry=tenacity.retry_if_exception_type(NetworkInterfaceNotFound),
353+
wait=tenacity.wait_exponential(multiplier=0.02, max=1),
354+
stop=tenacity.stop_after_delay(3), reraise=True)
351355
@privileged.link_cmd.entrypoint
352356
def set_link_attribute(device, namespace, **attributes):
353357
_run_iproute_link("set", device, namespace, **attributes)
@@ -378,7 +382,8 @@ def set_link_bridge_master(device, bridge, namespace=None):
378382

379383
@tenacity.retry(
380384
retry=tenacity.retry_if_exception_type(
381-
netlink_exceptions.NetlinkDumpInterrupted),
385+
(netlink_exceptions.NetlinkDumpInterrupted,
386+
NetworkInterfaceNotFound)),
382387
wait=tenacity.wait_exponential(multiplier=0.02, max=1),
383388
stop=tenacity.stop_after_delay(8),
384389
reraise=True)

0 commit comments

Comments
 (0)