commit 39d0a1f0421f0176fb4c3b3851f3b176c13d89f2
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Aug 14 09:50:08 2013 +0200
NetTestController: add detection of slave disconnect
This commit adds detection of slaves being disconnected while the
controller is waiting for a response.
When this happens an Exception is raised resulting in the recipe failing
and remaining slaves being deconfigured.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 4 ++++
lnst/Controller/NetTestController.py | 12 ++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 76e35b5..5876347 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -148,6 +148,10 @@ class Machine(object):
if not self._configured:
return
+ #connection to the slave was closed
+ if not self._msg_dispatcher.get_connection(self._id):
+ return
+
self._rpc_call("kill_cmds")
if deconfigure:
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index a90a3dc..fee06ed 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -612,7 +612,12 @@ class MessageDispatcher(ConnectionHandler):
def wait_for_result(self, machine_id):
wait = True
while wait:
+ connected_slaves = self._connections.keys()
+
messages = self.check_connections()
+
+ remaining_slaves = self._connections.keys()
+
for msg in messages:
if msg[1]["type"] == "result" and msg[0] ==
machine_id:
wait = False
@@ -620,6 +625,13 @@ class MessageDispatcher(ConnectionHandler):
else:
self._process_message(msg)
+ if connected_slaves != remaining_slaves:
+ disconnected_slaves = set(connected_slaves) -\
+ set(remaining_slaves)
+ msg = "Slaves " + str(list(disconnected_slaves)) + \
+ " disconnected from the controller."
+ raise NetTestError(msg)
+
return result
def _process_message(self, message):