Skip to content

Commit

Permalink
Merge branch 'RESTAPI-1035-fix-ssh-errors-handling' into 'master'
Browse files Browse the repository at this point in the history
Fixed SSH connection error catching.

See merge request firecrest/firecrest!277
  • Loading branch information
Elia committed Feb 27, 2024
2 parents 38b579c + 9b23b5a commit e90892a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed demo images dependency declarations preventing docker-compose to build successfully.
- Fixed check when submitted an empty batch file on `POST /compute/jobs/upload`
- Fixed error message when `GET /status/systems` encounters error in one filesystem
- Fixed SSH connection error catching

### Changed

Expand Down
8 changes: 6 additions & 2 deletions src/common/cscs_api_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ def get_username(header):
return {"result": True, "reason":"", "username": decoded['preferred_username']}

def in_str(stringval, substring):
return substring in stringval
if isinstance(stringval, str):
return substring in stringval
else:
return False


# SSH certificates creation
# returns pub key certificate name
Expand Down Expand Up @@ -958,7 +962,7 @@ def check_command_error(error_str, error_code, service_msg):
header = {"X-Permission-Denied": "User does not have permissions to access path"}
return {"description": service_msg, "error": error_str, "status_code": 400, "header": header}

if ("File exists" in error_str) and ("mkdir: cannot create directory" in error_str or "ln: failed to create symbolic link" in error_str):
if in_str(error_str,"File exists") and (in_str(error_str,"mkdir: cannot create directory") or in_str(error_str,"ln: failed to create symbolic link")):
header = {"X-Exists": "targetPath already exists"}
return {"description": service_msg, "error": error_str, "status_code": 400, "header": header}

Expand Down

0 comments on commit e90892a

Please sign in to comment.