commit 017f3d21aa78e2ed6e6ef0ee3a0ff3e18d148adc
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Sep 20 12:50:10 2013 +0200
Machine: exceptions during deconfiguration fix
This patch adds a few try-except blocks for machine deconfiguration. The
important part is that the slave is always disconnected in the end, and
that dynamic devices get detached when something fails.
Exceptions during deconfiguration caused that the controller never
disconnected from the slave, and the slave would be locked listening on
this socket. This would cause problems when there are multiple recipes
being processed in a single lnst-ctl call.
It is also important to continue the cleanup of remaining machines when
cleanup on one machine fails.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 30 ++++++++++++++++++------------
lnst/Controller/NetTestController.py | 5 ++++-
2 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index fdd400a..4ac7d2f 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -158,24 +158,30 @@ class Machine(object):
#connection to the slave was closed
if not self._msg_dispatcher.get_connection(self._id):
- #we still need to remove virtual interfaces
- if deconfigure:
- for iface in reversed(self._interfaces):
- if isinstance(iface, VirtualInterface):
- iface.cleanup()
return
- self._rpc_call("kill_cmds")
+ try:
+ self._rpc_call("kill_cmds")
- if deconfigure:
+ if deconfigure:
+ for iface in reversed(self._interfaces):
+ iface.deconfigure()
+ iface.cleanup()
+
+ self._rpc_call("bye")
+ except:
+ #cleanup is only meaningful on dynamic interfaces, and should
+ #always be called when deconfiguration happens- especially
+ #when something on the slave breaks during deconfiguration
for iface in reversed(self._interfaces):
- iface.deconfigure()
+ if not isinstance(iface, VirtualInterface):
+ continue
iface.cleanup()
+ raise
+ finally:
+ self._msg_dispatcher.disconnect_slave(self.get_id())
- self._rpc_call("bye")
- self._msg_dispatcher.disconnect_slave(self.get_id())
-
- self._configured = False
+ self._configured = False
def _timeout_handler(self, signum, frame):
msg = "RPC connection to machine %s timed out" % self.get_id()
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index c2d7d65..a88058f 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -405,7 +405,10 @@ class NetTestController:
for machine_id, machine in self._machines.iteritems():
if machine.is_configured():
- machine.cleanup(deconfigure)
+ try:
+ machine.cleanup(deconfigure)
+ except:
+ pass
#clean-up slave logger
self._log_ctl.remove_slave(machine_id)