diff --git a/awx/main/dispatch/__init__.py b/awx/main/dispatch/__init__.py index 6ea1ae1686..5a6606ebdc 100644 --- a/awx/main/dispatch/__init__.py +++ b/awx/main/dispatch/__init__.py @@ -1,6 +1,7 @@ import os import psycopg import select +from copy import deepcopy from contextlib import contextmanager @@ -94,8 +95,8 @@ class PubSub(object): def create_listener_connection(): - conf = settings.DATABASES['default'].copy() - conf['OPTIONS'] = conf.get('OPTIONS', {}).copy() + conf = deepcopy(settings.DATABASES['default']) + conf['OPTIONS'] = deepcopy(conf.get('OPTIONS', {})) # Modify the application name to distinguish from other connections the process might use conf['OPTIONS']['application_name'] = get_application_name(settings.CLUSTER_HOST_ID, function='listener') diff --git a/awx/main/wsrelay.py b/awx/main/wsrelay.py index d6f9c2e0b1..8a1a834295 100644 --- a/awx/main/wsrelay.py +++ b/awx/main/wsrelay.py @@ -2,6 +2,7 @@ import json import logging import asyncio from typing import Dict +from copy import deepcopy import ipaddress @@ -302,14 +303,17 @@ class WebSocketRelayManager(object): self.stats_mgr.start() # Set up a pg_notify consumer for allowing web nodes to "provision" and "deprovision" themselves gracefully. - database_conf = settings.DATABASES['default'].copy() - database_conf['OPTIONS'] = database_conf.get('OPTIONS', {}).copy() + database_conf = deepcopy(settings.DATABASES['default']) + database_conf['OPTIONS'] = deepcopy(database_conf.get('OPTIONS', {})) for k, v in settings.LISTENER_DATABASES.get('default', {}).items(): database_conf[k] = v for k, v in settings.LISTENER_DATABASES.get('default', {}).get('OPTIONS', {}).items(): database_conf['OPTIONS'][k] = v + if 'PASSWORD' in database_conf: + database_conf['OPTIONS']['password'] = database_conf.pop('PASSWORD') + task = None # Establishes a websocket connection to /websocket/relay on all API servers @@ -320,7 +324,6 @@ class WebSocketRelayManager(object): dbname=database_conf['NAME'], host=database_conf['HOST'], user=database_conf['USER'], - password=database_conf['PASSWORD'], port=database_conf['PORT'], **database_conf.get("OPTIONS", {}), )