diff --git a/agkyra/protocol.py b/agkyra/protocol.py index 665454659b8b4594b2e5cdd811c59b58a6f9d9e3..393959a94a854a0f7331f60e0c16adb7df5abd2c 100644 --- a/agkyra/protocol.py +++ b/agkyra/protocol.py @@ -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 diff --git a/agkyra/syncer/messaging.py b/agkyra/syncer/messaging.py index 33494238670eb33e9f56a5f6efaa8ce449b2f27d..67df4c7b11ced4a34df7e506e72cb6f7e8842e99 100644 --- a/agkyra/syncer/messaging.py +++ b/agkyra/syncer/messaging.py @@ -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) diff --git a/agkyra/syncer/pithos_client.py b/agkyra/syncer/pithos_client.py index 42f37f9fa8010f2693fb87e20b6e578f7b4e67f8..8a20eb509d00dfe08399041807ecf74689ab3063 100644 --- a/agkyra/syncer/pithos_client.py +++ b/agkyra/syncer/pithos_client.py @@ -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 = {}