mirror of
https://github.com/ansible/awx.git
synced 2026-03-24 04:15:02 -02:30
Merge pull request #6747 from chrismeyersfsu/fix-redis_logs
fix redis logs Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -95,19 +95,16 @@ class BroadcastConsumer(AsyncJsonWebsocketConsumer):
|
|||||||
try:
|
try:
|
||||||
WebsocketSecretAuthHelper.is_authorized(self.scope)
|
WebsocketSecretAuthHelper.is_authorized(self.scope)
|
||||||
except Exception:
|
except Exception:
|
||||||
# TODO: log ip of connected client
|
logger.warn(f"client '{self.channel_name}' failed to authorize against the broadcast endpoint.")
|
||||||
logger.warn("Broadcast client failed to authorize for reason.")
|
|
||||||
await self.close()
|
await self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: log ip of connected client
|
|
||||||
logger.info(f"Broadcast client connected.")
|
|
||||||
await self.accept()
|
await self.accept()
|
||||||
await self.channel_layer.group_add(settings.BROADCAST_WEBSOCKET_GROUP_NAME, self.channel_name)
|
await self.channel_layer.group_add(settings.BROADCAST_WEBSOCKET_GROUP_NAME, self.channel_name)
|
||||||
|
logger.info(f"client '{self.channel_name}' joined the broadcast group.")
|
||||||
|
|
||||||
async def disconnect(self, code):
|
async def disconnect(self, code):
|
||||||
# TODO: log ip of disconnected client
|
logger.info("client '{self.channel_name}' disconnected from the broadcast group.")
|
||||||
logger.info("Client disconnected")
|
|
||||||
await self.channel_layer.group_discard(settings.BROADCAST_WEBSOCKET_GROUP_NAME, self.channel_name)
|
await self.channel_layer.group_discard(settings.BROADCAST_WEBSOCKET_GROUP_NAME, self.channel_name)
|
||||||
|
|
||||||
async def internal_message(self, event):
|
async def internal_message(self, event):
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class WebsocketTask():
|
|||||||
|
|
||||||
async def connect(self, attempt):
|
async def connect(self, attempt):
|
||||||
from awx.main.consumers import WebsocketSecretAuthHelper # noqa
|
from awx.main.consumers import WebsocketSecretAuthHelper # noqa
|
||||||
logger.debug(f"{self.name} connect attempt {attempt} to {self.remote_host}")
|
logger.debug(f"Connection from {self.name} to {self.remote_host} attempt number {attempt}.")
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Can not put get_channel_layer() in the init code because it is in the init
|
Can not put get_channel_layer() in the init code because it is in the init
|
||||||
@@ -83,7 +83,7 @@ class WebsocketTask():
|
|||||||
if attempt > 0:
|
if attempt > 0:
|
||||||
await asyncio.sleep(settings.BROADCAST_WEBSOCKET_RECONNECT_RETRY_RATE_SECONDS)
|
await asyncio.sleep(settings.BROADCAST_WEBSOCKET_RECONNECT_RETRY_RATE_SECONDS)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
logger.warn(f"{self.name} connection to {self.remote_host} cancelled")
|
logger.warn(f"Connection from {self.name} to {self.remote_host} cancelled")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
uri = f"{self.protocol}://{self.remote_host}:{self.remote_port}/websocket/{self.endpoint}/"
|
uri = f"{self.protocol}://{self.remote_host}:{self.remote_port}/websocket/{self.endpoint}/"
|
||||||
@@ -94,22 +94,25 @@ class WebsocketTask():
|
|||||||
async with aiohttp.ClientSession(headers={'secret': secret_val},
|
async with aiohttp.ClientSession(headers={'secret': secret_val},
|
||||||
timeout=timeout) as session:
|
timeout=timeout) as session:
|
||||||
async with session.ws_connect(uri, ssl=self.verify_ssl, heartbeat=20) as websocket:
|
async with session.ws_connect(uri, ssl=self.verify_ssl, heartbeat=20) as websocket:
|
||||||
|
logger.info(f"Connection from {self.name} to {self.remote_host} established.")
|
||||||
self.stats.record_connection_established()
|
self.stats.record_connection_established()
|
||||||
attempt = 0
|
attempt = 0
|
||||||
await self.run_loop(websocket)
|
await self.run_loop(websocket)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
# TODO: Check if connected and disconnect
|
# TODO: Check if connected and disconnect
|
||||||
# Possibly use run_until_complete() if disconnect is async
|
# Possibly use run_until_complete() if disconnect is async
|
||||||
logger.warn(f"{self.name} connection to {self.remote_host} cancelled")
|
logger.warn(f"Connection from {self.name} to {self.remote_host} cancelled.")
|
||||||
self.stats.record_connection_lost()
|
self.stats.record_connection_lost()
|
||||||
raise
|
raise
|
||||||
except client_exceptions.ClientConnectorError as e:
|
except client_exceptions.ClientConnectorError as e:
|
||||||
logger.warn(f"Failed to connect to {self.remote_host}: '{e}'. Reconnecting ...")
|
logger.warn(f"Connection from {self.name} to {self.remote_host} failed: '{e}'.")
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
logger.warn(f"Timeout while trying to connect to {self.remote_host}. Reconnecting ...")
|
logger.warn(f"Connection from {self.name} to {self.remote_host} timed out.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Early on, this is our canary. I'm not sure what exceptions we can really encounter.
|
# Early on, this is our canary. I'm not sure what exceptions we can really encounter.
|
||||||
logger.warn(f"Websocket broadcast client exception {type(e)} {e}")
|
logger.warn(f"Connection from {self.name} to {self.remote_host} failed for unknown reason: '{e}'.")
|
||||||
|
else:
|
||||||
|
logger.warn(f"Connection from {self.name} to {self.remote_host} list.")
|
||||||
|
|
||||||
self.stats.record_connection_lost()
|
self.stats.record_connection_lost()
|
||||||
self.start(attempt=attempt + 1)
|
self.start(attempt=attempt + 1)
|
||||||
@@ -160,9 +163,9 @@ class BroadcastWebsocketManager(object):
|
|||||||
new_remote_hosts = set(future_remote_hosts) - set(current_remote_hosts)
|
new_remote_hosts = set(future_remote_hosts) - set(current_remote_hosts)
|
||||||
|
|
||||||
if deleted_remote_hosts:
|
if deleted_remote_hosts:
|
||||||
logger.warn(f"{self.local_hostname} going to remove {deleted_remote_hosts} from the websocket broadcast list")
|
logger.warn(f"Removing {deleted_remote_hosts} from websocket broadcast list")
|
||||||
if new_remote_hosts:
|
if new_remote_hosts:
|
||||||
logger.warn(f"{self.local_hostname} going to add {new_remote_hosts} to the websocket broadcast list")
|
logger.warn(f"Adding {new_remote_hosts} to websocket broadcast list")
|
||||||
|
|
||||||
for h in deleted_remote_hosts:
|
for h in deleted_remote_hosts:
|
||||||
self.broadcast_tasks[h].cancel()
|
self.broadcast_tasks[h].cancel()
|
||||||
|
|||||||
@@ -1106,9 +1106,9 @@ LOGGING = {
|
|||||||
'handlers': ['console', 'file', 'tower_warnings'],
|
'handlers': ['console', 'file', 'tower_warnings'],
|
||||||
'level': 'WARNING',
|
'level': 'WARNING',
|
||||||
},
|
},
|
||||||
'celery': { # for celerybeat connection warnings
|
'daphne': {
|
||||||
'handlers': ['console', 'file', 'tower_warnings'],
|
'handlers': ['console', 'file', 'tower_warnings'],
|
||||||
'level': 'WARNING',
|
'level': 'INFO',
|
||||||
},
|
},
|
||||||
'rest_framework.request': {
|
'rest_framework.request': {
|
||||||
'handlers': ['console', 'file', 'tower_warnings'],
|
'handlers': ['console', 'file', 'tower_warnings'],
|
||||||
@@ -1139,6 +1139,10 @@ LOGGING = {
|
|||||||
'awx.main.dispatch': {
|
'awx.main.dispatch': {
|
||||||
'handlers': ['dispatcher'],
|
'handlers': ['dispatcher'],
|
||||||
},
|
},
|
||||||
|
'awx.main.consumers': {
|
||||||
|
'handlers': ['console', 'file', 'tower_warnings'],
|
||||||
|
'level': 'INFO',
|
||||||
|
},
|
||||||
'awx.main.wsbroadcast': {
|
'awx.main.wsbroadcast': {
|
||||||
'handlers': ['wsbroadcast'],
|
'handlers': ['wsbroadcast'],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user