Skip to content
Snippets Groups Projects
Commit d74b1790 authored by Chris Hines's avatar Chris Hines
Browse files

use HTTP status 599 to signify an SSH timeout

parent 0112192f
No related branches found
No related tags found
3 merge requests!77Revert "disable agressive kill and restart",!64Test,!62Dev
Pipeline #15921 passed
...@@ -10,6 +10,7 @@ import flask_restful ...@@ -10,6 +10,7 @@ import flask_restful
from . import api, app from . import api, app
from .sshwrapper import Ssh, SshAgentException, SftpPermissionException, SftpException, SshCtrlException, SshExecException from .sshwrapper import Ssh, SshAgentException, SftpPermissionException, SftpException, SshCtrlException, SshExecException
from .tunnelstat import SSHSession from .tunnelstat import SSHSession
import subprocess
class AppParamsException(Exception): class AppParamsException(Exception):
pass pass
...@@ -228,8 +229,10 @@ def wrap_execute(sess, host, user, cmd, bastion=None,stdin=None, sshport="22", b ...@@ -228,8 +229,10 @@ def wrap_execute(sess, host, user, cmd, bastion=None,stdin=None, sshport="22", b
return apiabort(401,message="".format(host)) return apiabort(401,message="".format(host))
# This exception is raised if the remove command had a non-zero return code # This exception is raised if the remove command had a non-zero return code
except SshExecException as e: except SshExecException as e:
return apiabort(400,message="{}".format(e)) return apiabort(400, message="{}".format(e))
# Any other exceptions. This should never be reached. # Any other exceptions. This should never be reached.
except subprocess.TimedoutExpired as e:
return apiabort(599, message="{}".format(e))
except Exception as e: except Exception as e:
import traceback import traceback
logger.error('JobStat.get: Exception {}'.format(e)) logger.error('JobStat.get: Exception {}'.format(e))
...@@ -477,7 +480,7 @@ class AppLaunch(Resource): ...@@ -477,7 +480,7 @@ class AppLaunch(Resource):
logger.error(e) logger.error(e)
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
#flask_restful.abort(500,message="AppUrl failed in some unexpected way") #flask_restful.abort(500,message="AppUrl failed in some unexpected way")
return apiabort(500,message="AppUrl failed in some unexpected way") return apiabort(500,message="AppLaunc failed in some unexpected way")
logger.debug('application launched, returning') logger.debug('application launched, returning')
return None, 200 return None, 200
......
...@@ -337,7 +337,8 @@ class Ssh: ...@@ -337,7 +337,8 @@ class Ssh:
except subprocess.TimeoutExpired as e: except subprocess.TimeoutExpired as e:
logger.debug('cmd timed out') logger.debug('cmd timed out')
logger.debug("exception execute") logger.debug("exception execute")
raise SshExecException(message="A program timed out on the backend server") raise e
#raise SshExecException(message="A program timed out on the backend server")
if exec_p.returncode == 255: if exec_p.returncode == 255:
logger.error(stderr) logger.error(stderr)
sess.kill() sess.kill()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment