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

CommonRepo: fix 'find job' hanging in cluster.py #3207

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
16 changes: 12 additions & 4 deletions workflows/pipe-common/pipeline/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

MAX_RETRY_COUNT = 5
WAITING_DELAY = 3
QSTAT_WAITING_DELAY = 60
QACCT_RETRY_COUNT = 100


class AbstractCluster(object):
Expand Down Expand Up @@ -90,8 +92,8 @@ def _execute_job(self, job_command, job_identifier, max_retry_count):
.format(MAX_RETRY_COUNT, job_command, run_job_exit_code, run_job_result, run_job_error))

def _is_job_in_queue(self, job_identifier):
qacct_command = self.QSTAT_CMD_TEMPLATE % job_identifier
_, _, exit_code = utils.run(qacct_command)
qstat_command = self.QSTAT_CMD_TEMPLATE % job_identifier
_, _, exit_code = utils.run(qstat_command)
return exit_code == 0

def _verify_error_state(self, job_identifier):
Expand All @@ -104,9 +106,15 @@ def _verify_error_state(self, job_identifier):
raise RuntimeError("Job is in error state. %s" % error_reason)

def _find_job(self, job_identifier):
while True:
sleep(WAITING_DELAY)
while self._is_job_in_queue(job_identifier):
self._verify_error_state(job_identifier)
sleep(QSTAT_WAITING_DELAY)
continue
retry_count = 0
qacct_output = ""
while retry_count < QACCT_RETRY_COUNT:
retry_count += 1
sleep(WAITING_DELAY)
qacct_command = self.QACCT_CMD_TEMPLATE % job_identifier
qacct_output, _, exit_code = utils.run(qacct_command)
if exit_code == 0:
Expand Down