mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Fix up job run types so that we aren't auto-starting new jobs. Fix up
job dependency generator to call the right new methods for generating inventory and project updates
This commit is contained in:
parent
bb630fddbc
commit
03249e59f3
@ -133,9 +133,9 @@ class SimpleDAG(object):
|
||||
def get_tasks():
|
||||
''' Fetch all Tower tasks that are relevant to the task management system '''
|
||||
# TODO: Replace this when we can grab all objects in a sane way
|
||||
graph_jobs = [j for j in Job.objects.filter(status__in=('new', 'waiting', 'pending', 'running'))]
|
||||
graph_inventory_updates = [iu for iu in InventoryUpdate.objects.filter(status__in=('new', 'waiting', 'pending', 'running'))]
|
||||
graph_project_updates = [pu for pu in ProjectUpdate.objects.filter(status__in=('new', 'waiting', 'pending', 'running'))]
|
||||
graph_jobs = [j for j in Job.objects.filter(status__in=('pending', 'waiting', 'running'))]
|
||||
graph_inventory_updates = [iu for iu in InventoryUpdate.objects.filter(status__in=('pending', 'waiting', 'running'))]
|
||||
graph_project_updates = [pu for pu in ProjectUpdate.objects.filter(status__in=('pending', 'waiting', 'running'))]
|
||||
all_actions = sorted(graph_jobs + graph_inventory_updates + graph_project_updates, key=lambda task: task.created)
|
||||
return all_actions
|
||||
|
||||
@ -165,7 +165,7 @@ def rebuild_graph(message):
|
||||
return None
|
||||
running_tasks = filter(lambda t: t.status == 'running', all_sorted_tasks)
|
||||
waiting_tasks = filter(lambda t: t.status != 'running', all_sorted_tasks)
|
||||
new_tasks = filter(lambda t: t.status == 'new', all_sorted_tasks)
|
||||
new_tasks = filter(lambda t: t.status == 'pending', all_sorted_tasks)
|
||||
|
||||
# Check running tasks and make sure they are active in celery
|
||||
print("Active celery tasks: " + str(active_tasks))
|
||||
|
@ -740,6 +740,7 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions):
|
||||
self.start_args = json_args
|
||||
self.save()
|
||||
self.start_args = encrypt_field(self, 'start_args')
|
||||
self.status = 'pending'
|
||||
self.save()
|
||||
# notify_task_runner.delay(dict(task_type="inventory_update", id=self.id, metadata=kwargs))
|
||||
return True
|
||||
|
@ -309,11 +309,11 @@ class Job(UnifiedJob, JobOptions):
|
||||
if obj.inventory_source in inventory_sources:
|
||||
inventory_sources_found.append(obj.inventory_source)
|
||||
if not project_found and self.project.scm_update_on_launch:
|
||||
dependencies.append(self.project.project_updates.create())
|
||||
dependencies.append(self.project.create_project_update(launch_type='dependency'))
|
||||
if inventory_sources.count(): # and not has_setup_failures? Probably handled as an error scenario in the task runner
|
||||
for source in inventory_sources:
|
||||
if not source in inventory_sources_found:
|
||||
dependencies.append(source.inventory_updates.create())
|
||||
dependencies.append(source.create_inventory_update(launch_type='dependency'))
|
||||
return dependencies
|
||||
|
||||
def signal_start(self, **kwargs):
|
||||
@ -331,6 +331,7 @@ class Job(UnifiedJob, JobOptions):
|
||||
self.start_args = json_args
|
||||
self.save()
|
||||
self.start_args = encrypt_field(self, 'start_args')
|
||||
self.status = 'pending'
|
||||
self.save()
|
||||
# notify_task_runner.delay(dict(task_type="ansible_playbook", id=self.id))
|
||||
return True
|
||||
|
@ -358,6 +358,7 @@ class ProjectUpdate(UnifiedJob, ProjectOptions):
|
||||
self.start_args = json_args
|
||||
self.save()
|
||||
self.start_args = encrypt_field(self, 'start_args')
|
||||
self.status = 'pending'
|
||||
self.save()
|
||||
# notify_task_runner.delay(dict(task_type="project_update", id=self.id, metadata=kwargs))
|
||||
return True
|
||||
|
@ -456,7 +456,7 @@ class UnifiedJob(PolymorphicModel, CommonModelNameNotUnique):
|
||||
|
||||
def start(self, error_callback, **kwargs):
|
||||
task_class = self._get_task_class()
|
||||
if not self.can_start: # self.status == 'waiting': # FIXME: Why did this not include "new"?
|
||||
if not self.can_start:
|
||||
return False
|
||||
needed = self._get_passwords_needed_to_start()
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user