From: Ondrej Lichtner <olichtne(a)redhat.com>
Unfortunatelly when an ip address is configured via netlink (a create ip
address message is sent) we don't receive a response message that would
indicate success or failure.
Because of that we've sometimes seen race condition issues with
configuring ipv6 addresses (that take slightly longer to create) on the
controller that was trying wait for the "tentative" state to disappear
from the ip addresses (because the address wasn't created yet there was
nothing to wait for).
By adding a wait loop here the race condition disappears - either the ip
address appears or an exception is raised indicationg a potential
problem with the configuration.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Devices/Device.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lnst/Devices/Device.py b/lnst/Devices/Device.py
index 30b82f06..c31a018f 100644
--- a/lnst/Devices/Device.py
+++ b/lnst/Devices/Device.py
@@ -558,6 +558,14 @@ def _ip_add_one(self, addr):
if ip not in self.ips:
self._ipr_wrapper("addr", "add", index=self.ifindex,
address=str(ip), mask=ip.prefixlen)
+ for i in range(5):
+ logging.debug("Waiting for ip address to be added {} of
5".format(i))
+ time.sleep(1)
+ self._if_manager.rescan_devices()
+ if addr in self.ips:
+ break
+ else:
+ raise DeviceError("Failed to configure ip address
{}".format(str(ip)))
def ip_add(self, addr):
"""add an ip address or a list of ip addresses
--
2.31.1
Show replies by date