Skip to content

Commit 59bd343

Browse files
committed
Tree: propagation channels shouldn't update Task rc
Use a temporary fix to avoid the gateways to update Task's rc dict. The permanent fix will be to clean this mess with Task Event Handlers (see at least #369 and #231). Change-Id: I2049a4b6ce3931f1b245b29326ba3daa065b36ba
1 parent 4018851 commit 59bd343

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

lib/ClusterShell/Task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,7 @@ def _pchannel(self, gateway, metaworker):
13181318
wrkcls = self.default('distant_worker')
13191319
chanworker = wrkcls(gateway, command=metaworker.invoke_gateway,
13201320
handler=chan, stderr=True, timeout=timeout)
1321+
chanworker._update_task_rc = False
13211322
# gateway is special! define worker._fanout to not rely on the
13221323
# engine's fanout, and use the special value FANOUT_UNLIMITED to
13231324
# always allow registration of gateways

lib/ClusterShell/Worker/Worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def __init__(self, handler):
110110
# cannot currently be changed afterwards.
111111
self._fanout = FANOUT_DEFAULT
112112

113+
# Update task rc? [private]
114+
# TODO: to be replaced with Task Event Handlers
115+
self._update_task_rc = True
116+
113117
# Parent task (once bound)
114118
self.task = None #: worker's task when scheduled or None
115119
self.started = False #: set to True when worker has started
@@ -155,10 +159,11 @@ def _on_start(self, key):
155159

156160
def _on_close(self, key, rc=None):
157161
"""Called to generate events when the Worker is closing."""
158-
# rc may be None here for example when called from StreamClient
159-
# Only update task if rc is not None.
160-
if rc is not None:
161-
self.task._rc_set(self, key, rc)
162+
if self._update_task_rc:
163+
# rc may be None here for example when called from StreamClient
164+
# Only update task if rc is not None.
165+
if rc is not None:
166+
self.task._rc_set(self, key, rc)
162167

163168
self.current_node = key
164169
self.current_rc = rc

tests/TreeTaskTest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def test_shell_auto_tree_dummy(self):
3737

3838
self.assertRaises(RouteResolvingError, task.run, "/bin/hostname",
3939
nodes="dummy-node", stderr=True)
40-
# FIXME: should probably be None
41-
self.assertEqual(task.max_retcode(), 255)
40+
self.assertEqual(task.max_retcode(), None)
4241

4342
def test_shell_auto_tree_noconf(self):
4443
"""test task shell auto tree [no topology.conf]"""

0 commit comments

Comments
 (0)