mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 22:49:32 -02:30
Only get receptor.conf lock in k8s environment
- Writing to receptor.conf only takes place in K8S, so only get a lock if IS_K8S is true
This commit is contained in:
committed by
Jeff Bradberry
parent
e0c9013d9c
commit
301807466d
@@ -48,11 +48,22 @@ class ReceptorConnectionType(Enum):
|
|||||||
STREAMTLS = 2
|
STREAMTLS = 2
|
||||||
|
|
||||||
|
|
||||||
def get_receptor_sockfile():
|
def read_receptor_config():
|
||||||
lock = FileLock(__RECEPTOR_CONF_LOCKFILE)
|
# for K8S deployments, getting a lock is necessary as another process
|
||||||
with lock:
|
# may be re-writing the config at this time
|
||||||
|
if settings.IS_K8S:
|
||||||
|
lock = FileLock(__RECEPTOR_CONF_LOCKFILE)
|
||||||
|
with lock:
|
||||||
|
with open(__RECEPTOR_CONF, 'r') as f:
|
||||||
|
return yaml.safe_load(f)
|
||||||
|
else:
|
||||||
with open(__RECEPTOR_CONF, 'r') as f:
|
with open(__RECEPTOR_CONF, 'r') as f:
|
||||||
data = yaml.safe_load(f)
|
return yaml.safe_load(f)
|
||||||
|
|
||||||
|
|
||||||
|
def get_receptor_sockfile():
|
||||||
|
data = read_receptor_config()
|
||||||
|
|
||||||
for section in data:
|
for section in data:
|
||||||
for entry_name, entry_data in section.items():
|
for entry_name, entry_data in section.items():
|
||||||
if entry_name == 'control-service':
|
if entry_name == 'control-service':
|
||||||
@@ -68,10 +79,7 @@ def get_tls_client(use_stream_tls=None):
|
|||||||
if not use_stream_tls:
|
if not use_stream_tls:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
lock = FileLock(__RECEPTOR_CONF_LOCKFILE)
|
data = read_receptor_config()
|
||||||
with lock:
|
|
||||||
with open(__RECEPTOR_CONF, 'r') as f:
|
|
||||||
data = yaml.safe_load(f)
|
|
||||||
for section in data:
|
for section in data:
|
||||||
for entry_name, entry_data in section.items():
|
for entry_name, entry_data in section.items():
|
||||||
if entry_name == 'tls-client':
|
if entry_name == 'tls-client':
|
||||||
|
|||||||
Reference in New Issue
Block a user