Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return maxrc properly for Rsh Worker #448

Merged
merged 6 commits into from
Sep 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/ClusterShell/Worker/Rsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import os
import shlex
import re

from ClusterShell.Worker.Exec import ExecClient, CopyClient, ExecWorker

Expand All @@ -35,6 +36,12 @@ class RshClient(ExecClient):
Rsh EngineClient.
"""

def __init__(self, node, command, worker, stderr, timeout, autoclose=False,
rank=None):
ExecClient.__init__(self, node, command, worker, stderr, timeout,
autoclose, rank)
self.rsh_rc = None

def _build_cmd(self):
"""
Build the shell command line to start the rsh commmand.
Expand All @@ -59,8 +66,26 @@ def _build_cmd(self):
cmd_l.append("%s" % self.key) # key is the node
cmd_l.append("%s" % self.command)

# rsh does not properly return exit status
# force the exit status to be printed out
cmd_l.append("; echo XXRETCODE: $?")

return (cmd_l, None)

def _on_nodeset_msgline(self, nodes, msg, sname):
"""Override _on_nodeset_msgline to parse magic return code"""
match = re.search("^XXRETCODE: (\d+)$", msg.decode())
if match:
self.rsh_rc = int(match.group(1))
else:
ExecClient._on_nodeset_msgline(self, nodes, msg, sname)

def _on_nodeset_close(self, nodes, rc):
"""Override _on_nodeset_close to return rsh_rc"""
if (rc == 0 or rc == 1) and self.rsh_rc is not None:
rc = self.rsh_rc
ExecClient._on_nodeset_close(self, nodes, rc)


class RcpClient(CopyClient):
"""
Expand Down