mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 15:06:02 -03:30
reregister node when they come back online
* Nodes are marked offline, then deleted; given enough time. Nodes can come back for various reasions (i.e. netsplit). When they come back, have them recreate the node Instance if AWX_AUTO_DEPROVISION_INSTANCES is True. Otherwise, do nothing. The do nothing case will show up in the logs as celery job tracebacks as they fail to be self aware.
This commit is contained in:
@@ -8,6 +8,7 @@ from django.db import models
|
||||
from django.conf import settings
|
||||
|
||||
from awx.main.utils.filters import SmartFilter
|
||||
from awx.main.utils.pglock import advisory_lock
|
||||
|
||||
___all__ = ['HostManager', 'InstanceManager', 'InstanceGroupManager']
|
||||
|
||||
@@ -86,6 +87,20 @@ class InstanceManager(models.Manager):
|
||||
return node[0]
|
||||
raise RuntimeError("No instance found with the current cluster host id")
|
||||
|
||||
def register(self, uuid=settings.SYSTEM_UUID, hostname=settings.CLUSTER_HOST_ID):
|
||||
with advisory_lock('instance_registration_%s' % hostname):
|
||||
instance = self.filter(hostname=hostname)
|
||||
if instance.exists():
|
||||
return (False, instance[0])
|
||||
instance = self.create(uuid=uuid, hostname=hostname)
|
||||
return (True, instance)
|
||||
|
||||
def get_or_register(self):
|
||||
if settings.AWX_AUTO_DEPROVISION_INSTANCES:
|
||||
return self.register()
|
||||
else:
|
||||
return (False, self.me())
|
||||
|
||||
def active_count(self):
|
||||
"""Return count of active Tower nodes for licensing."""
|
||||
return self.all().count()
|
||||
|
||||
Reference in New Issue
Block a user