Skip to content

Commit

Permalink
Merge pull request ansible#5519 from fosterseth/fix-inv-source-blocking
Browse files Browse the repository at this point in the history
Remove inventory source update blocking

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
  • Loading branch information
softwarefactory-project-zuul[bot] authored Dec 19, 2019
2 parents cf57d59 + b26b8e7 commit 497f460
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
7 changes: 1 addition & 6 deletions awx/main/scheduler/dependency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class DependencyGraph(object):
INVENTORY_UPDATES = 'inventory_updates'

JOB_TEMPLATE_JOBS = 'job_template_jobs'
JOB_INVENTORY_IDS = 'job_inventory_ids'

SYSTEM_JOB = 'system_job'
INVENTORY_SOURCE_UPDATES = 'inventory_source_updates'
Expand All @@ -40,8 +39,6 @@ def __init__(self, queue):
Track runnable job related project and inventory to ensure updates
don't run while a job needing those resources is running.
'''
# inventory_id -> True / False
self.data[self.JOB_INVENTORY_IDS] = {}

# inventory_source_id -> True / False
self.data[self.INVENTORY_SOURCE_UPDATES] = {}
Expand Down Expand Up @@ -77,7 +74,6 @@ def mark_inventory_source_update(self, inventory_source_id):
self.data[self.INVENTORY_SOURCE_UPDATES][inventory_source_id] = False

def mark_job_template_job(self, job):
self.data[self.JOB_INVENTORY_IDS][job.inventory_id] = False
self.data[self.JOB_TEMPLATE_JOBS][job.job_template_id] = False

def mark_workflow_job(self, job):
Expand All @@ -87,8 +83,7 @@ def can_project_update_run(self, job):
return self.data[self.PROJECT_UPDATES].get(job.project_id, True)

def can_inventory_update_run(self, job):
return self.data[self.JOB_INVENTORY_IDS].get(job.inventory_source.inventory_id, True) and \
self.data[self.INVENTORY_SOURCE_UPDATES].get(job.inventory_source_id, True)
return self.data[self.INVENTORY_SOURCE_UPDATES].get(job.inventory_source_id, True)

def can_job_run(self, job):
if self.data[self.PROJECT_UPDATES].get(job.project_id, True) is True and \
Expand Down
30 changes: 30 additions & 0 deletions awx/main/tests/functional/task_management/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,33 @@ def test_job_not_blocking_project_update(default_instance_group, job_template_fa
dependency_graph = DependencyGraph(None)
dependency_graph.add_job(job)
assert not dependency_graph.is_job_blocked(project_update)


@pytest.mark.django_db
def test_job_not_blocking_inventory_update(default_instance_group, job_template_factory, inventory_source_factory):
objects = job_template_factory('jt', organization='org1', project='proj',
inventory='inv', credential='cred',
jobs=["job"])
job = objects.jobs["job"]
job.instance_group = default_instance_group
job.status = "running"
job.save()

with mock.patch("awx.main.scheduler.TaskManager.start_task"):
task_manager = TaskManager()
task_manager._schedule()

inv = objects.inventory
inv_source = inventory_source_factory("ec2")
inv_source.source = "ec2"
inv.inventory_sources.add(inv_source)
inventory_update = inv_source.create_inventory_update()
inventory_update.instance_group = default_instance_group
inventory_update.status = "pending"
inventory_update.save()

assert not task_manager.is_job_blocked(inventory_update)

dependency_graph = DependencyGraph(None)
dependency_graph.add_job(job)
assert not dependency_graph.is_job_blocked(inventory_update)

0 comments on commit 497f460

Please sign in to comment.