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 016f5187a5
)
This commit is contained in:
parent
93cf601354
commit
1d2a1c68c0
@ -400,6 +400,10 @@ def set_link_flags(device, namespace, flags):
|
||||
_run_iproute_link("set", device, namespace, flags=new_flags)
|
||||
|
||||
|
||||
@tenacity.retry(
|
||||
retry=tenacity.retry_if_exception_type(NetworkInterfaceNotFound),
|
||||
wait=tenacity.wait_exponential(multiplier=0.02, max=1),
|
||||
stop=tenacity.stop_after_delay(3), reraise=True)
|
||||
@privileged.link_cmd.entrypoint
|
||||
def set_link_attribute(device, namespace, **attributes):
|
||||
_run_iproute_link("set", device, namespace, **attributes)
|
||||
@ -430,7 +434,8 @@ def set_link_bridge_master(device, bridge, namespace=None):
|
||||
|
||||
@tenacity.retry(
|
||||
retry=tenacity.retry_if_exception_type(
|
||||
netlink_exceptions.NetlinkDumpInterrupted),
|
||||
(netlink_exceptions.NetlinkDumpInterrupted,
|
||||
NetworkInterfaceNotFound)),
|
||||
wait=tenacity.wait_exponential(multiplier=0.02, max=1),
|
||||
stop=tenacity.stop_after_delay(8),
|
||||
reraise=True)
|
||||
|
Loading…
Reference in New Issue
Block a user