Skip to content

Commit b0b76fb

Browse files
committed
tree mode: fix error with intermediate gateways (#471)
Intermediate gateways create a TreeWorker with a topology passed by the parent node and a new root node, and instantiate their own PropagationNodeRouter object. When such TreeWorker is scheduled, we should set the task's default router from it properly. The error seen was: ... File "ClusterShell/Propagation.py", line 411, in ev_close self.task.router.mark_unreachable(gateway) AttributeError: 'NoneType' object has no attribute 'mark_unreachable' Fixes #471
1 parent c421133 commit b0b76fb

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/ClusterShell/Task.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,25 @@ def load_topology(self, topology_file):
421421
"""
422422
self.topology = TopologyParser(topology_file).tree(_getshorthostname())
423423

424-
def _default_router(self):
425-
if self.router is None:
426-
self.router = PropagationTreeRouter(str(self.topology.root.nodeset),
427-
self.topology)
424+
def _default_router(self, router=None):
425+
"""
426+
Helper to instantiate or bind a default PropagationTreeRouter
427+
for the task which can then be shared by multiple workers.
428+
Called by a TreeWorker when it is scheduled with this task.
429+
"""
430+
if router is None:
431+
if self.router is None:
432+
# Init router with the task's topology (e.g. root node)
433+
self.router = \
434+
PropagationTreeRouter(str(self.topology.root.nodeset),
435+
self.topology)
436+
else:
437+
if self.router is not None:
438+
# Update default router if a different one is used by a worker.
439+
logger = logging.getLogger(__name__)
440+
logger.debug("_default_router: overriding previous default " \
441+
"router %s with %s", self.router, router)
442+
self.router = router
428443
return self.router
429444

430445
def default(self, default_key, def_val=None):

lib/ClusterShell/Worker/Tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _set_task(self, task):
202202
DistantWorker._set_task(self, task)
203203
# Now bound to task - initalize router
204204
self.topology = self.topology or task.topology
205-
self.router = self.router or task._default_router()
205+
self.router = task._default_router(self.router)
206206
self._launch(self.nodes)
207207
self._check_ini()
208208

0 commit comments

Comments
 (0)