From f3e73bbed8b42bad31dc139326786ea5f5498c6a Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 16 Oct 2018 08:54:03 -0400 Subject: [PATCH] don't call rabbitmqctl forget_cluster_node for isolated instances --- .../management/commands/deprovision_instance.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/awx/main/management/commands/deprovision_instance.py b/awx/main/management/commands/deprovision_instance.py index f295fddd6f..e501f5e2ce 100644 --- a/awx/main/management/commands/deprovision_instance.py +++ b/awx/main/management/commands/deprovision_instance.py @@ -41,14 +41,18 @@ class Command(BaseCommand): with advisory_lock('instance_registration_%s' % hostname): instance = Instance.objects.filter(hostname=hostname) if instance.exists(): + isolated = instance.first().is_isolated() instance.delete() print("Instance Removed") - result = subprocess.Popen("rabbitmqctl forget_cluster_node rabbitmq@{}".format(hostname), shell=True).wait() - if result != 0: - print("Node deprovisioning may have failed when attempting to " - "remove the RabbitMQ instance {} from the cluster".format(hostname)) - else: + if isolated: print('Successfully deprovisioned {}'.format(hostname)) + else: + result = subprocess.Popen("rabbitmqctl forget_cluster_node rabbitmq@{}".format(hostname), shell=True).wait() + if result != 0: + print("Node deprovisioning may have failed when attempting to " + "remove the RabbitMQ instance {} from the cluster".format(hostname)) + else: + print('Successfully deprovisioned {}'.format(hostname)) print('(changed: True)') else: print('No instance found matching name {}'.format(hostname))