From f3e514246ed8330e734e5b360ac03f15ba11376c Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 27 Feb 2017 11:28:29 -0500 Subject: [PATCH 1/2] cancel jobs dependent on inv update --- awx/main/models/inventory.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 020121120b..1e156986f1 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -23,6 +23,7 @@ from awx.main.fields import AutoOneToOneField, ImplicitRoleField from awx.main.managers import HostManager from awx.main.models.base import * # noqa from awx.main.models.unified_jobs import * # noqa +from awx.main.models.jobs import Job from awx.main.models.mixins import ResourceMixin from awx.main.models.notifications import ( NotificationTemplate, @@ -1276,6 +1277,11 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions, JobNotificationMixin): def get_notification_friendly_name(self): return "Inventory Update" + def cancel(self): + res = super(InventoryUpdate, self).cancel() + map(lambda x: x.cancel(), Job.objects.filter(dependent_jobs__in=[self.id])) + return res + class CustomInventoryScript(CommonModelNameNotUnique, ResourceMixin): From c1bace87ab7f417dc745fe39a47685365de7a7d9 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 27 Feb 2017 11:37:29 -0500 Subject: [PATCH 2/2] only cancel deps if we can cancel the inv update --- awx/main/models/inventory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 1e156986f1..387277c5e9 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1279,7 +1279,8 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions, JobNotificationMixin): def cancel(self): res = super(InventoryUpdate, self).cancel() - map(lambda x: x.cancel(), Job.objects.filter(dependent_jobs__in=[self.id])) + if res: + map(lambda x: x.cancel(), Job.objects.filter(dependent_jobs__in=[self.id])) return res