Merge pull request #4800 from AlanCoding/bad_node_redo

Avoid signal_start override for workflow job spawn
This commit is contained in:
Alan Rominger 2017-01-18 16:31:39 -05:00 committed by GitHub
commit 56e2e28dc8
3 changed files with 11 additions and 6 deletions

View File

@ -606,11 +606,10 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin):
evars.update(extra_vars)
self.update_fields(extra_vars=json.dumps(evars))
def signal_start(self, **kwargs):
# Block cases that would cause the task manager to error
if self.inventory_id is None or self.project_id is None:
return False
return super(Job, self).signal_start(**kwargs)
def _resources_sufficient_for_launch(self):
if self.job_type == PERM_INVENTORY_SCAN:
return self.inventory_id is not None
return not (self.inventory_id is None or self.project_id is None)
def display_artifacts(self):
'''

View File

@ -561,6 +561,9 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
"Override in child classes, None value indicates this is not configurable"
return None
def _resources_sufficient_for_launch(self):
return True
def __unicode__(self):
return u'%s-%s-%s' % (self.created, self.id, self.status)

View File

@ -121,7 +121,10 @@ class TaskManager():
job = spawn_node.unified_job_template.create_unified_job(**kv)
spawn_node.job = job
spawn_node.save()
can_start = job.signal_start(**kv)
if job._resources_sufficient_for_launch():
can_start = job.signal_start(**kv)
else:
can_start = False
if not can_start:
job.status = 'failed'
job.job_explanation = _("Job spawned from workflow could not start because it "