Skip to content

Commit

Permalink
Make this more resilient to errors in submission
Browse files Browse the repository at this point in the history
If submission fails, the 'stage' subdirectory won't exist; watch out for
that.

Also, catch exceptions from SCPClient and delete the job.
  • Loading branch information
remram44 committed Jul 16, 2015
1 parent 79aaa85 commit ea76636
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tej/remotes/default/commands/status
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ else # [ "$status" = incomplete -o "$status" = created ]
if [ -n "$started_date" ]; then
echo "Created $(date "--date=$started_date")" >&2
fi
cd "$job_root/stage"
pwd
cd "$job_root"
echo "$(pwd)/stage"
exit 1
fi
15 changes: 11 additions & 4 deletions tej/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,17 @@ def submit(self, job_id, directory, script=None):
logger.debug("Server created directory %s", target)

# Upload to directory
scp_client = scp.SCPClient(self.get_client().get_transport())
scp_client.put(str(Path(directory)),
str(target),
recursive=True)
try:
scp_client = scp.SCPClient(self.get_client().get_transport())
scp_client.put(str(Path(directory)),
str(target),
recursive=True)
except BaseException as e:
try:
self.delete(job_id)
except:
raise e
raise
logger.debug("Files uploaded")

# Submit job
Expand Down

0 comments on commit ea76636

Please sign in to comment.