From 64491a3b547d90bbc0da52d96ba0d95472abca22 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Fri, 26 Apr 2024 15:28:42 -0400 Subject: [PATCH 1/2] awx modules wait on event processing finished This change makes "wait: true" for jobs and syncs look at the event_processing_finished instead of finished field. Right now there is a race condition where a module might try to delete an inventory, but the events for an inventory sync have not yet finished. We have a RelatedJobsPreventDeleteMixin that checks for this condition. --- awx_collection/plugins/module_utils/controller_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx_collection/plugins/module_utils/controller_api.py b/awx_collection/plugins/module_utils/controller_api.py index 37c784e0a2c8..e1e7a3641305 100644 --- a/awx_collection/plugins/module_utils/controller_api.py +++ b/awx_collection/plugins/module_utils/controller_api.py @@ -1038,7 +1038,7 @@ def wait_on_url(self, url, object_name, object_type, timeout=30, interval=2): # Grab our start time to compare against for the timeout start = time.time() result = self.get_endpoint(url) - while not result['json']['finished']: + while not result['json']['event_processing_finished']: # If we are past our time out fail with a message if timeout and timeout < time.time() - start: # Account for Legacy messages From f3fd2dd9053e1ff3483d29f22c584c12f19c6177 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Fri, 26 Apr 2024 15:58:27 -0400 Subject: [PATCH 2/2] bulk jobs don't have event_processing_finished --- awx_collection/plugins/module_utils/controller_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awx_collection/plugins/module_utils/controller_api.py b/awx_collection/plugins/module_utils/controller_api.py index e1e7a3641305..0f48fc2dff1c 100644 --- a/awx_collection/plugins/module_utils/controller_api.py +++ b/awx_collection/plugins/module_utils/controller_api.py @@ -1038,7 +1038,10 @@ def wait_on_url(self, url, object_name, object_type, timeout=30, interval=2): # Grab our start time to compare against for the timeout start = time.time() result = self.get_endpoint(url) - while not result['json']['event_processing_finished']: + wait_on_field = 'event_processing_finished' + if wait_on_field not in result['json']: + wait_on_field = 'finished' + while not result['json'][wait_on_field]: # If we are past our time out fail with a message if timeout and timeout < time.time() - start: # Account for Legacy messages