From 6e228248c1d47651a5efa0b41ef2f21bab129b44 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 27 Oct 2016 12:58:27 -0400 Subject: [PATCH] remove fail_on_job_failure from the workflow status PR --- awx/api/serializers.py | 6 +---- ...rkflow_job_template_workflow_nodes_list.md | 7 +++--- .../0045_v310_workflow_failure_condition.py | 24 ------------------- awx/main/models/workflow.py | 8 ++----- .../tests/functional/models/test_workflow.py | 17 ++++--------- .../tests/unit/models/test_workflow_unit.py | 2 -- 6 files changed, 12 insertions(+), 52 deletions(-) delete mode 100644 awx/main/migrations/0045_v310_workflow_failure_condition.py diff --git a/awx/api/serializers.py b/awx/api/serializers.py index d681fac426..ad84b9e421 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -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) diff --git a/awx/api/templates/api/workflow_job_template_workflow_nodes_list.md b/awx/api/templates/api/workflow_job_template_workflow_nodes_list.md index e6b078a23f..9e5d0f688f 100644 --- a/awx/api/templates/api/workflow_job_template_workflow_nodes_list.md +++ b/awx/api/templates/api/workflow_job_template_workflow_nodes_list.md @@ -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" %} \ No newline at end of file diff --git a/awx/main/migrations/0045_v310_workflow_failure_condition.py b/awx/main/migrations/0045_v310_workflow_failure_condition.py deleted file mode 100644 index 9bafa0feb6..0000000000 --- a/awx/main/migrations/0045_v310_workflow_failure_condition.py +++ /dev/null @@ -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), - ), - ] diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 3bc0608cfc..50739829fe 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -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 {} diff --git a/awx/main/tests/functional/models/test_workflow.py b/awx/main/tests/functional/models/test_workflow.py index aa622d996a..0c3d5d88be 100644 --- a/awx/main/tests/functional/models/test_workflow.py +++ b/awx/main/tests/functional/models/test_workflow.py @@ -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() diff --git a/awx/main/tests/unit/models/test_workflow_unit.py b/awx/main/tests/unit/models/test_workflow_unit.py index bc7e9b5bce..add8379727 100644 --- a/awx/main/tests/unit/models/test_workflow_unit.py +++ b/awx/main/tests/unit/models/test_workflow_unit.py @@ -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: [])