mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 03:01:06 -03:30
remove partial dependency job id logic
* Late in the release we added job dependency tracking to the DB. We decided not to use this information in the scheduler. However, I half-ass added code to the scheduler to use it. Note that we still determine inv and job update dependency by using a hack of the related creation time, job.created-2 and job.created-1 respectively. This removes any use of job dependent id expect for purposes of chain failing.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
# Python
|
# Python
|
||||||
import json
|
import json
|
||||||
import itertools
|
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.utils import decrypt_field_value
|
from awx.main.utils import decrypt_field_value
|
||||||
@@ -62,35 +61,13 @@ class PartialModelDict(object):
|
|||||||
def task_impact(self):
|
def task_impact(self):
|
||||||
raise RuntimeError("Inherit and implement me")
|
raise RuntimeError("Inherit and implement me")
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def merge_values(cls, values):
|
|
||||||
grouped_results = itertools.groupby(values, key=lambda value: value['id'])
|
|
||||||
|
|
||||||
merged_values = []
|
|
||||||
for k, g in grouped_results:
|
|
||||||
groups = list(g)
|
|
||||||
merged_value = {}
|
|
||||||
for group in groups:
|
|
||||||
for key, val in group.iteritems():
|
|
||||||
if not merged_value.get(key):
|
|
||||||
merged_value[key] = val
|
|
||||||
elif val != merged_value[key]:
|
|
||||||
if isinstance(merged_value[key], list):
|
|
||||||
if val not in merged_value[key]:
|
|
||||||
merged_value[key].append(val)
|
|
||||||
else:
|
|
||||||
old_val = merged_value[key]
|
|
||||||
merged_value[key] = [old_val, val]
|
|
||||||
merged_values.append(merged_value)
|
|
||||||
return merged_values
|
|
||||||
|
|
||||||
|
|
||||||
class JobDict(PartialModelDict):
|
class JobDict(PartialModelDict):
|
||||||
FIELDS = (
|
FIELDS = (
|
||||||
'id', 'status', 'job_template_id', 'inventory_id', 'project_id',
|
'id', 'status', 'job_template_id', 'inventory_id', 'project_id',
|
||||||
'launch_type', 'limit', 'allow_simultaneous', 'created',
|
'launch_type', 'limit', 'allow_simultaneous', 'created',
|
||||||
'job_type', 'celery_task_id', 'project__scm_update_on_launch',
|
'job_type', 'celery_task_id', 'project__scm_update_on_launch',
|
||||||
'forks', 'start_args', 'dependent_jobs__id',
|
'forks', 'start_args',
|
||||||
)
|
)
|
||||||
model = Job
|
model = Job
|
||||||
|
|
||||||
@@ -113,8 +90,7 @@ class JobDict(PartialModelDict):
|
|||||||
kv = {
|
kv = {
|
||||||
'status__in': status
|
'status__in': status
|
||||||
}
|
}
|
||||||
merged = PartialModelDict.merge_values(cls.model.objects.filter(**kv).values(*cls.get_db_values()))
|
return [cls(o) for o in cls.model.objects.filter(**kv).values(*cls.get_db_values())]
|
||||||
return [cls(o) for o in merged]
|
|
||||||
|
|
||||||
|
|
||||||
class ProjectUpdateDict(PartialModelDict):
|
class ProjectUpdateDict(PartialModelDict):
|
||||||
|
|||||||
Reference in New Issue
Block a user