mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Provision the instance before booting anything
There was a race condition because the callback reciever tried to run this code:
File "/awx_devel/awx/main/management/commands/run_callback_receiver.py", line 31, in handle
CallbackBrokerWorker(),
File "/awx_devel/awx/main/dispatch/worker/callback.py", line 49, in __init__
self.subsystem_metrics = s_metrics.Metrics(auto_pipe_execute=False)
File "/awx_devel/awx/main/analytics/subsystem_metrics.py", line 156, in __init__
self.instance_name = Instance.objects.me().hostname
Before get_or_register was being called by the dispatcher.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2015 Ansible, Inc.
|
# Copyright (c) 2015 Ansible, Inc.
|
||||||
# All Rights Reserved
|
# All Rights Reserved
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
from awx.main.models import Instance
|
from awx.main.models import Instance
|
||||||
@@ -22,8 +22,9 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
def _register_hostname(self, hostname, node_type, uuid):
|
def _register_hostname(self, hostname, node_type, uuid):
|
||||||
if not hostname:
|
if not hostname:
|
||||||
return
|
(changed, instance) = Instance.objects.get_or_register()
|
||||||
(changed, instance) = Instance.objects.register(hostname=hostname, node_type=node_type, uuid=uuid)
|
else:
|
||||||
|
(changed, instance) = Instance.objects.register(hostname=hostname, node_type=node_type, uuid=uuid)
|
||||||
if changed:
|
if changed:
|
||||||
print("Successfully registered instance {}".format(hostname))
|
print("Successfully registered instance {}".format(hostname))
|
||||||
else:
|
else:
|
||||||
@@ -32,8 +33,6 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
if not options.get('hostname'):
|
|
||||||
raise CommandError("Specify `--hostname` to use this command.")
|
|
||||||
self.changed = False
|
self.changed = False
|
||||||
self._register_hostname(options.get('hostname'), options.get('node_type'), options.get('uuid'))
|
self._register_hostname(options.get('hostname'), options.get('node_type'), options.get('uuid'))
|
||||||
if self.changed:
|
if self.changed:
|
||||||
|
|||||||
@@ -612,10 +612,6 @@ def cluster_node_heartbeat():
|
|||||||
if inst.hostname == settings.CLUSTER_HOST_ID:
|
if inst.hostname == settings.CLUSTER_HOST_ID:
|
||||||
this_inst = inst
|
this_inst = inst
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
(changed, this_inst) = Instance.objects.get_or_register()
|
|
||||||
if changed:
|
|
||||||
logger.info("Registered tower control node '{}'".format(this_inst.hostname))
|
|
||||||
|
|
||||||
inspect_execution_nodes(instance_list)
|
inspect_execution_nodes(instance_list)
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,6 @@ set -e
|
|||||||
|
|
||||||
wait-for-migrations
|
wait-for-migrations
|
||||||
|
|
||||||
|
awx-manage provision_instance
|
||||||
|
|
||||||
supervisord -c /etc/supervisord_task.conf
|
supervisord -c /etc/supervisord_task.conf
|
||||||
|
|||||||
Reference in New Issue
Block a user