mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 05:47:38 -02:30
I had the luck of running into this race condition that broke my deployment. No instance was ever able to register because on running "awx-manage" in some check of a setting, it would end up failing here with
```
File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/awx/conf/license.py", line 10, in _get_validated_license_data
return get_licenser().validate()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/awx/main/utils/licensing.py", line 453, in validate
automated_since = int(Instance.objects.order_by('id').first().created.timestamp())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'created'
```
This commit is contained in:
@@ -450,7 +450,12 @@ class Licenser(object):
|
|||||||
if first_host:
|
if first_host:
|
||||||
automated_since = int(first_host.first_automation.timestamp())
|
automated_since = int(first_host.first_automation.timestamp())
|
||||||
else:
|
else:
|
||||||
automated_since = int(Instance.objects.order_by('id').first().created.timestamp())
|
try:
|
||||||
|
automated_since = int(Instance.objects.order_by('id').first().created.timestamp())
|
||||||
|
except AttributeError:
|
||||||
|
# In the odd scenario that create_preload_data was not run, there are no hosts
|
||||||
|
# Then we CAN end up here before any instance has registered
|
||||||
|
automated_since = int(time.time())
|
||||||
instance_count = int(attrs.get('instance_count', 0))
|
instance_count = int(attrs.get('instance_count', 0))
|
||||||
attrs['current_instances'] = current_instances
|
attrs['current_instances'] = current_instances
|
||||||
attrs['automated_instances'] = automated_instances
|
attrs['automated_instances'] = automated_instances
|
||||||
|
|||||||
Reference in New Issue
Block a user