Return a 503 when the Salt master is down; for commands and auths

This commit is contained in:
Seth House 2015-04-22 18:22:17 -06:00
parent 036c14cc59
commit e83f73d3e8

View File

@ -394,6 +394,9 @@ def hypermedia_handler(*args, **kwargs):
except (salt.exceptions.EauthAuthenticationError,
salt.exceptions.TokenAuthenticationError):
raise cherrypy.HTTPError(401)
except (salt.exceptions.SaltDaemonNotRunning,
salt.exceptions.SaltReqTimeoutError) as exc:
raise cherrypy.HTTPError(503, exc.strerror)
except cherrypy.CherryPyException:
raise
except Exception as exc:
@ -1361,6 +1364,10 @@ class Login(LowDataAdapter):
]
}}
'''
if not self.api.is_master_running():
raise salt.exceptions.SaltDaemonNotRunning(
'Salt Master is not available.')
# the urlencoded_processor will wrap this in a list
if isinstance(cherrypy.serving.request.lowstate, list):
creds = cherrypy.serving.request.lowstate[0]