Skip to content

Commit

Permalink
fixed error check
Browse files Browse the repository at this point in the history
  • Loading branch information
jdorsch committed Oct 18, 2024
1 parent fc42ecc commit 0b3689e
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/common/cscs_api_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,45 +521,50 @@ def exec_remote_command(headers, system_name, system_addr, action, file_transfer

if stderr_errno == 0:
if file_transfer == "download":
result = {"error": 0, "msg": outlines}
result = {"error": 0, "msg": outlines}
elif stderr_errda and not (in_str(stderr_errda,"Could not chdir to home directory") or in_str(stderr_errda,"scancel: Terminating job")):
result = {"error": 1, "msg": stderr_errda}
result = {"error": 1, "msg": stderr_errda}
elif in_str(stdout_errda, "No such file"): # in case that error is 0 and the msg is on the stdout (like with some file)
result = {"error": 1, "msg": stdout_errda}
result = {"error": 1, "msg": stdout_errda}
elif in_str(stdout_errda, "no read permission"): # in case that error is 0 and the msg is on the stdout (like with some file)
result = {"error": 1, "msg": stdout_errda}
result = {"error": 1, "msg": stdout_errda}
elif in_str(stdout_errda, "cannot open"): # in case that error is 0 and the msg is on the stdout (like with some file)
result = {"error": 1, "msg": stdout_errda}
result = {"error": 1, "msg": stdout_errda}
# only in case of SLURM scheduler: stderr_errno == 0 always, and output (error or not) in stderr_errda
elif in_str(stderr_errda, "scancel: Terminating job"):
if in_str(stderr_errda, "error"):
result = {"error": 1, "msg": stderr_errda}
else:
result = {"error": 0, "msg": stderr_errda}

else:
result = {"error": 0, "msg": outlines}
elif stderr_errno > 0:
# Solving when stderr_errno = 1 and $HOME is not mounted:
# stderr_errno = 1
result = {"error": 0, "msg": outlines}
elif stderr_errno != 0:
# First solving specific errors
if stderr_errno == 7:
result = {"error": 7, "msg": "Failed to connect to staging area server"}
elif stderr_errno == 124:
result = {"error": 124, "msg": "Command has finished with timeout signal"}
elif stdout_errno == -2:
result = {"error": -2, "msg": "Receive ready timeout exceeded"}
elif stderr_errno == -1:
result = {"error": -1, "msg": "No exit status was provided by the server"}
# solving error of $HOME not present
# stderr_errda = "Could not chdir to home directory /users/eirinik: No such file or directory
# ERROR: you must specify a project account (-A <account>)sbatch: error: cli_filter plugin terminated with error"
if not HOME_ENABLED and in_str(stderr_errda, "Could not chdir to home directory"):
# checking for 2nd 'directory' string (first is at index 33)
# 2nd comes after username
logging.info(f"$HOME directory is not enabled"
f" (F7T_HOME_ENABLED={HOME_ENABLED})")
if DEBUG_MODE:
logging.debug(f"$HOME directory is not enabled"
f" (F7T_HOME_ENABLED={HOME_ENABLED})")
idx = stderr_errda.index("directory", 33)
# len(directory) = 9
result = {"error": stderr_errno, "msg": stderr_errda[idx+9:]}

elif stderr_errno == 7:
result = {"error": 7, "msg": "Failed to connect to staging area server"}
elif stderr_errno == 124:
result = {"error": 124, "msg": "Command has finished with timeout signal"}
result = {"error": stderr_errno, "msg": stderr_errda[idx+9:]}
else:
result = {"error": stderr_errno, "msg": stderr_errda or stdout_errda}
result = {"error": stderr_errno, "msg": stderr_errda or stdout_errda}
elif len(stderr_errda) > 0:
result = {"error": 1, "msg": stderr_errda}
elif stdout_errno == -2:
result = {"error": -2, "msg": "Receive ready timeout exceeded"}
elif stderr_errno == -1:
result = {"error": -1, "msg": "No exit status was provided by the server"}



# first if paramiko exception raise
except paramiko.ssh_exception.NoValidConnectionsError as e:
Expand Down

0 comments on commit 0b3689e

Please sign in to comment.