remove fail_on_job_failure from the workflow status PR

This commit is contained in:
AlanCoding 2016-10-27 12:58:27 -04:00
parent a2c972e513
commit 6e228248c1
6 changed files with 12 additions and 52 deletions

View File

@ -2249,15 +2249,11 @@ class WorkflowNodeBaseSerializer(BaseSerializer):
success_nodes = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
failure_nodes = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
always_nodes = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
fail_on_job_failure = serializers.BooleanField(
help_text=('If set to true, and if the job runs and fails, '
'the workflow is marked as failed.'),
default=True)
class Meta:
fields = ('*', '-name', '-description', 'id', 'url', 'related',
'unified_job_template', 'success_nodes', 'failure_nodes', 'always_nodes',
'inventory', 'credential', 'job_type', 'job_tags', 'skip_tags', 'limit', 'skip_tags', 'fail_on_job_failure')
'inventory', 'credential', 'job_type', 'job_tags', 'skip_tags', 'limit', 'skip_tags')
def get_related(self, obj):
res = super(WorkflowNodeBaseSerializer, self).get_related(obj)

View File

@ -7,8 +7,9 @@ the subsequent actions are to:
- run nodes contained in "failure_nodes" or "always_nodes" if job failed
- run nodes contained in "success_nodes" or "always_nodes" if job succeeded
The workflow is marked as failed if any jobs run as part of that workflow fail
and have the field `fail_on_job_failure` set to true. If not, the workflow
job is marked as successful.
The workflow job is marked as `successful` if all of the jobs running as
a part of the workflow job have completed, and the workflow job has not
been canceled. Even if a job within the workflow has failed, the workflow
job will not be marked as failed.
{% include "api/sub_list_create_api_view.md" %}

View File

@ -1,24 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0044_v310_project_playbook_files'),
]
operations = [
migrations.AddField(
model_name='workflowjobnode',
name='fail_on_job_failure',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='workflowjobtemplatenode',
name='fail_on_job_failure',
field=models.BooleanField(default=True),
),
]

View File

@ -60,10 +60,6 @@ class WorkflowNodeBase(CreatedModifiedModel):
default=None,
on_delete=models.SET_NULL,
)
fail_on_job_failure = models.BooleanField(
blank=True,
default=True,
)
# Prompting-related fields
inventory = models.ForeignKey(
'Inventory',
@ -157,7 +153,7 @@ class WorkflowNodeBase(CreatedModifiedModel):
Return field names that should be copied from template node to job node.
'''
return ['workflow_job', 'unified_job_template',
'inventory', 'credential', 'char_prompts', 'fail_on_job_failure']
'inventory', 'credential', 'char_prompts']
class WorkflowJobTemplateNode(WorkflowNodeBase):
# TODO: Ensure the API forces workflow_job_template being set
@ -404,7 +400,7 @@ class WorkflowJob(UnifiedJob, WorkflowJobOptions, JobNotificationMixin, Workflow
return RunWorkflowJob
def _has_failed(self):
return self.workflow_job_nodes.filter(job__status='failed', fail_on_job_failure=True).exists()
return False
def socketio_emit_data(self):
return {}

View File

@ -92,20 +92,14 @@ class TestWorkflowJobTemplate:
@pytest.mark.django_db
class TestWorkflowJobFailure:
"""
Tests to re-implement if workflow failure status is introduced in
a future Tower version.
"""
@pytest.fixture
def wfj(self):
return WorkflowJob.objects.create(name='test-wf-job')
def test_workflow_has_failed(self, wfj):
"""
Test that a single failed node with fail_on_job_failure = true
leads to the entire WF being marked as failed
"""
job = Job.objects.create(name='test-job', status='failed')
# Node has a failed job connected
WorkflowJobNode.objects.create(workflow_job=wfj, job=job)
assert wfj._has_failed()
def test_workflow_not_failed_unran_job(self, wfj):
"""
Test that an un-ran node will not mark workflow job as failed
@ -124,8 +118,7 @@ class TestWorkflowJobFailure:
def test_workflow_not_failed_failed_job_but_okay(self, wfj):
"""
Test that a failed node will not mark workflow job as failed
if the fail_on_job_failure is set to false
"""
job = Job.objects.create(name='test-job', status='failed')
WorkflowJobNode.objects.create(workflow_job=wfj, job=job, fail_on_job_failure=False)
WorkflowJobNode.objects.create(workflow_job=wfj, job=job)
assert not wfj._has_failed()

View File

@ -139,7 +139,6 @@ class TestWorkflowJobCreate:
char_prompts=wfjt_node_no_prompts.char_prompts,
inventory=None, credential=None,
unified_job_template=wfjt_node_no_prompts.unified_job_template,
fail_on_job_failure=True,
workflow_job=workflow_job_unit)
def test_create_with_prompts(self, wfjt_node_with_prompts, workflow_job_unit, mocker):
@ -151,7 +150,6 @@ class TestWorkflowJobCreate:
inventory=wfjt_node_with_prompts.inventory,
credential=wfjt_node_with_prompts.credential,
unified_job_template=wfjt_node_with_prompts.unified_job_template,
fail_on_job_failure=True,
workflow_job=workflow_job_unit)
@mock.patch('awx.main.models.workflow.WorkflowNodeBase.get_parent_nodes', lambda self: [])