mirror of
https://github.com/xcat2/confluent.git
synced 2026-11-19 08:52:20 +00:00
Report request errors from console sessions like other requests
A request sent from within a console session, such as the power state check confetty makes, went through a handler that logged every failure as an unexpected 500 with a stack trace. A node with an unreachable BMC filled the trace log with TargetEndpointUnreachable. Share the error reporting of the main request loop, so the client gets the real error code and only unexpected failures are traced.
This commit is contained in:
@@ -165,26 +165,10 @@ async def sessionhdl(connection, authname, skipauth=False, cert=None):
|
||||
try:
|
||||
await process_request(
|
||||
connection, request, cfm, authdata, authname, skipauth)
|
||||
except exc.ConfluentException as e:
|
||||
if ((not isinstance(e, exc.LockedCredentials)) and
|
||||
e.apierrorcode == 500):
|
||||
tracelog.log(
|
||||
traceback.format_exc(), ltype=log.DataTypes.event,
|
||||
event=log.Events.stacktrace)
|
||||
await send_data(connection, {'errorcode': e.apierrorcode,
|
||||
'error': e.apierrorstr,
|
||||
'detail': e.get_error_body()})
|
||||
await send_data(connection, {'_requestdone': 1})
|
||||
except SystemExit:
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
tracelog.log(traceback.format_exc(), ltype=log.DataTypes.event,
|
||||
event=log.Events.stacktrace)
|
||||
await send_data(
|
||||
connection,
|
||||
{'errorcode': 500,
|
||||
'error': 'Unexpected error - ' + str(e)})
|
||||
await send_data(connection, {'_requestdone': 1})
|
||||
await send_request_error(connection, e)
|
||||
try:
|
||||
request = await tlvdata.recv(connection)
|
||||
except Exception:
|
||||
@@ -199,6 +183,28 @@ async def sessionhdl(connection, authname, skipauth=False, cert=None):
|
||||
pass
|
||||
|
||||
|
||||
async def send_request_error(connection, e):
|
||||
"""Report a failed request, call from the except clause that caught e"""
|
||||
if isinstance(e, exc.ConfluentException):
|
||||
# expected failures are not traced
|
||||
if ((not isinstance(e, exc.LockedCredentials)) and
|
||||
e.apierrorcode == 500):
|
||||
tracelog.log(
|
||||
traceback.format_exc(), ltype=log.DataTypes.event,
|
||||
event=log.Events.stacktrace)
|
||||
await send_data(connection, {'errorcode': e.apierrorcode,
|
||||
'error': e.apierrorstr,
|
||||
'detail': e.get_error_body()})
|
||||
else:
|
||||
tracelog.log(traceback.format_exc(), ltype=log.DataTypes.event,
|
||||
event=log.Events.stacktrace)
|
||||
await send_data(
|
||||
connection,
|
||||
{'errorcode': 500,
|
||||
'error': 'Unexpected error - ' + str(e)})
|
||||
await send_data(connection, {'_requestdone': 1})
|
||||
|
||||
|
||||
async def send_response(responses, connection):
|
||||
if responses is None:
|
||||
return
|
||||
@@ -337,14 +343,7 @@ async def term_interact(authdata, authname, ccons, cfm, connection, consession,
|
||||
await process_request(connection, data, cfm, authdata, authname,
|
||||
skipauth)
|
||||
except Exception as e:
|
||||
tracelog.log(traceback.format_exc(),
|
||||
ltype=log.DataTypes.event,
|
||||
event=log.Events.stacktrace)
|
||||
await send_data(
|
||||
connection,
|
||||
{'errorcode': 500,
|
||||
'error': 'Unexpected error - ' + str(e)})
|
||||
await send_data(connection, {'_requestdone': 1})
|
||||
await send_request_error(connection, e)
|
||||
continue
|
||||
if not consession:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user