Commit 20d65323 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

handle token renewal and other pithos errors

parent 66462277
......@@ -455,6 +455,16 @@ class WebSocketProtocol(WebSocket):
'STOP BACKEND, %s'% getattr(msg, 'objname', ''))
self.set_status(code=STATUS['CONTAINER ERROR'])
self.syncer.stop_all_daemons()
elif isinstance(msg, messaging.PithosAuthTokenError):
LOGGER.debug(
'STOP BACKEND, %s'% getattr(msg, 'objname', ''))
self.set_status(code=STATUS['TOKEN ERROR'])
self.syncer.stop_all_daemons()
elif isinstance(msg, messaging.PithosGenericError):
LOGGER.debug(
'STOP BACKEND, %s'% getattr(msg, 'objname', ''))
self.set_status(code=STATUS['CRITICAL ERROR'])
self.syncer.stop_all_daemons()
LOGGER.debug('Backend message: %s %s' % (msg.name, type(msg)))
# Limit the amount of messages consumed each time
max_consumption -= 1
......
......@@ -191,3 +191,17 @@ class PithosSyncEnabled(Message):
def __init__(self, *args, **kwargs):
Message.__init__(self, *args, **kwargs)
self.logger.info("Pithos sync is enabled")
class PithosGenericError(Message):
def __init__(self, *args, **kwargs):
Message.__init__(self, *args, **kwargs)
self.exc = kwargs["exc"]
self.logger.error(self.exc)
class PithosAuthTokenError(Message):
def __init__(self, *args, **kwargs):
Message.__init__(self, *args, **kwargs)
self.exc = kwargs["exc"]
self.logger.error(self.exc)
......@@ -287,8 +287,12 @@ class PithosFileClient(FileClient):
self.settings.set_pithos_enabled(False)
msg = messaging.PithosSyncDisabled(logger=logger)
self.settings.messager.put(msg)
elif e.status == 401:
msg = messaging.PithosAuthTokenError(logger=logger, exc=e)
self.settings.messager.put(msg)
else:
logger.error(e)
msg = messaging.PithosGenericError(logger=logger, exc=e)
self.settings.messager.put(msg)
return {}
self.objects = objects
upstream_all = {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment