Skip to content

Commit 57e15d3

Browse files
authored
fix: give detailed error message when ps is not installed
Signed-off-by: Jinzhe Zeng <[email protected]>
1 parent c8d2114 commit 57e15d3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dpdispatcher/machines/shell.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212

1313
class Shell(Machine):
14+
def bind_context(self, context):
15+
super().bind_context(context)
16+
self._has_ps = None
17+
1418
def gen_script(self, job):
1519
shell_script = super().gen_script(job)
1620
return shell_script
@@ -72,6 +76,15 @@ def check_status(self, job):
7276
if job_id == "":
7377
return JobStatus.unsubmitted
7478

79+
if self._has_ps is None:
80+
ret, stdin, stdout, stderr = self.context.block_call("which ps")
81+
if ret != 0:
82+
err_str = stderr.read().decode("utf-8")
83+
raise RuntimeError(
84+
"ps command is not found. Consider installing it using `apt-get install procps` or `yum install procps`\nerror message:%s\nreturn code %d\n"
85+
% (err_str, ret)
86+
)
87+
self._has_ps = True
7588
# mark defunct process as terminated
7689
ret, stdin, stdout, stderr = self.context.block_call(
7790
f"if ps -p {job_id} > /dev/null && ! (ps -o command -p {job_id} | grep defunct >/dev/null) ; then echo 1; fi"

0 commit comments

Comments
 (0)