Move InstanceLink creation and updating to the async tasks

So that they get applied in situations that do not go through the API.
This commit is contained in:
Jeff Bradberry
2022-09-01 11:34:21 -04:00
parent dfe6ce1ba8
commit 08c18d71bf
3 changed files with 12 additions and 11 deletions

View File

@@ -427,11 +427,11 @@ def on_instance_group_saved(sender, instance, created=False, raw=False, **kwargs
def on_instance_saved(sender, instance, created=False, raw=False, **kwargs):
if settings.IS_K8S and instance.node_type in (Instance.Types.EXECUTION,):
if instance.node_state == Instance.States.DEPROVISIONING:
from awx.main.tasks.receptor import wait_for_jobs # prevents circular import
from awx.main.tasks.receptor import remove_deprovisioned_node # prevents circular import
# wait for jobs on the node to complete, then delete the
# node and kick off write_receptor_config
connection.on_commit(lambda: wait_for_jobs.apply_async(instance.hostname))
connection.on_commit(lambda: remove_deprovisioned_node.apply_async([instance.hostname]))
if instance.node_state == Instance.States.INSTALLED:
from awx.main.tasks.receptor import write_receptor_config # prevents circular import