From: Ondrej Lichtner <olichtne(a)redhat.com>
When creation and configuration of a device fails, calling the
link_stats method would raise an Exception. Since this is always called
during deconfiguration, a configuration error would result in an
exception related crash of LNST and leave the Slave in an inconsistent
state - unable to run any more recipes unless manually restarted.
This commit fixes the issue by catching the exception and returning an
empty stats dictionary to indicate the failure. This is detected on the
Controller and the logging of device stats is skipped.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 15 +++++++++------
lnst/Slave/InterfaceManager.py | 6 +++++-
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 3725de6..b2cff15 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -309,12 +309,15 @@ class Machine(object):
if isinstance(iface, UnusedInterface):
continue
stats = iface.link_stats()
- logging.debug("%s:%s:%s: RX:\t bytes: %d\t packets: %d\t dropped:
%d" %
- (iface.get_netns(), iface.get_host(), iface.get_id(),
- stats["rx_bytes"], stats["rx_packets"],
stats["rx_dropped"]))
- logging.debug("%s:%s:%s: TX:\t bytes: %d\t packets: %d\t dropped:
%d" %
- (iface.get_netns(), iface.get_host(), iface.get_id(),
- stats["tx_bytes"], stats["tx_packets"],
stats["tx_dropped"]))
+ if stats:
+ logging.debug("%s:%s:%s: RX:\t bytes: %d\t packets: %d\t
dropped: %d" %
+ (iface.get_netns(), iface.get_host(),
+ iface.get_id(), stats["rx_bytes"],
+ stats["rx_packets"],
stats["rx_dropped"]))
+ logging.debug("%s:%s:%s: TX:\t bytes: %d\t packets: %d\t
dropped: %d" %
+ (iface.get_netns(), iface.get_host(),
+ iface.get_id(), stats["tx_bytes"],
+ stats["tx_packets"],
stats["tx_dropped"]))
self._rpc_call("kill_cmds")
for netns in self._namespaces:
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index 51aa6cc..05bd71e 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -647,7 +647,11 @@ class Device(object):
def link_stats(self):
stats = {"devname": self._name,
"hwaddr": self._hwaddr}
- out, _ = exec_cmd("ip -s link show %s" % self._name)
+ try:
+ out, _ = exec_cmd("ip -s link show %s" % self._name)
+ except:
+ return {}
+
lines = iter(out.split("\n"))
for line in lines:
if (len(line.split()) == 0):
--
2.9.3
Show replies by date