From 79d6ecc2ef2a146ebfdd8ecbd8f9642fd9b6e70c Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 21 May 2015 16:22:18 -0400 Subject: [PATCH 1/3] inherit child job finish status --- awx/main/models/inventory.py | 9 ++++++--- awx/main/models/projects.py | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index bee15004a7..5da86c9c7c 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1101,6 +1101,7 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions): 'credential', 'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars'] def save(self, *args, **kwargs): + print("Inventory source save called <%s, %s>" % (self.pk, self.status)) new_instance = bool(self.pk) # If update_fields has been specified, add our field names to it, # if it hasn't been specified, then we're just doing a normal save. @@ -1143,10 +1144,9 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions): return self.current_job.status elif not self.last_job: return 'never updated' - elif self.last_job_failed: - return 'failed' + # inherit the child job status else: - return 'successful' + return self.last_job.status else: return 'none' @@ -1231,6 +1231,9 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions): self.license_error = True if 'license_error' not in update_fields: update_fields.append('license_error') + + if 'status' in update_fields: + print("Calling inherited parent save for InventoryUpdate <%s, %s>" % (self.pk, self.status)) super(InventoryUpdate, self).save(*args, **kwargs) def get_absolute_url(self): diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index ddeb33e150..f1ed2aec8f 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -253,12 +253,16 @@ class Project(UnifiedJobTemplate, ProjectOptions): return self.current_job.status elif not self.last_job: return 'never updated' + # inherit the child job status on failure elif self.last_job_failed: - return 'failed' + return self.last_job.status + # Even on a successful child run, a missing project path overides + # the successful status elif not self.get_project_path(): return 'missing' + # Return the successful status else: - return 'successful' + return self.last_job.status elif not self.get_project_path(): return 'missing' else: @@ -353,6 +357,7 @@ class ProjectUpdate(UnifiedJob, ProjectOptions): return reverse('api:project_update_detail', args=(self.pk,)) def _update_parent_instance(self): + print("This should not print") parent_instance = self._get_parent_instance() if parent_instance: update_fields = self._update_parent_instance_no_save(parent_instance) From acc0f420cea6011f34b47906357e617d32a9dd83 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Fri, 22 May 2015 09:40:56 -0400 Subject: [PATCH 2/3] removed print statements --- awx/main/models/inventory.py | 1 - awx/main/models/projects.py | 1 - 2 files changed, 2 deletions(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 5da86c9c7c..3e9e67ac96 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1101,7 +1101,6 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions): 'credential', 'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars'] def save(self, *args, **kwargs): - print("Inventory source save called <%s, %s>" % (self.pk, self.status)) new_instance = bool(self.pk) # If update_fields has been specified, add our field names to it, # if it hasn't been specified, then we're just doing a normal save. diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index f1ed2aec8f..a762206476 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -357,7 +357,6 @@ class ProjectUpdate(UnifiedJob, ProjectOptions): return reverse('api:project_update_detail', args=(self.pk,)) def _update_parent_instance(self): - print("This should not print") parent_instance = self._get_parent_instance() if parent_instance: update_fields = self._update_parent_instance_no_save(parent_instance) From 0be448584931e3d0c21467d06f542672d5c1ded8 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Fri, 22 May 2015 11:48:22 -0400 Subject: [PATCH 3/3] removed debug print --- awx/main/models/inventory.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 3e9e67ac96..61d187735b 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1230,9 +1230,6 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions): self.license_error = True if 'license_error' not in update_fields: update_fields.append('license_error') - - if 'status' in update_fields: - print("Calling inherited parent save for InventoryUpdate <%s, %s>" % (self.pk, self.status)) super(InventoryUpdate, self).save(*args, **kwargs) def get_absolute_url(self):