mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Removed automatic failure of job template launch when last project update is failed and update on launch is enabled (#13796)
Co-authored-by: Jessica Steurer <70719005+jay-steurer@users.noreply.github.com>
This commit is contained in:
parent
875f1a82e4
commit
36d6ed9cac
@ -479,7 +479,7 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn
|
||||
RunProjectUpdate/RunInventoryUpdate.
|
||||
"""
|
||||
|
||||
if self.status not in ('error', 'failed'):
|
||||
if self.status not in ('error', 'failed') or self.scm_update_on_launch:
|
||||
return None
|
||||
|
||||
latest_update = self.project_updates.last()
|
||||
|
||||
@ -4,7 +4,7 @@ from unittest import mock # noqa
|
||||
import pytest
|
||||
|
||||
from awx.api.versioning import reverse
|
||||
from awx.main.models import Project
|
||||
from awx.main.models import Project, JobTemplate
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
@ -451,3 +451,19 @@ def test_project_list_ordering_with_duplicate_names(get, order_by, organization_
|
||||
results = get(reverse('api:project_list'), objects.superusers.admin, QUERY_STRING='order_by=%s' % order_by).data['results']
|
||||
project_ids[x] = [proj['id'] for proj in results]
|
||||
assert project_ids[0] == project_ids[1] == project_ids[2] == [1, 2, 3, 4, 5]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_project_failed_update(post, project, admin, inventory):
|
||||
"""Test to ensure failed projects with update on launch will create launch rather than error"""
|
||||
jt = JobTemplate.objects.create(project=project, inventory=inventory)
|
||||
# set project to update on launch and set status to failed
|
||||
project.update_fields(scm_update_on_launch=True)
|
||||
project.update()
|
||||
project.project_updates.last().update_fields(status='failed')
|
||||
response = post(reverse('api:job_template_launch', kwargs={'pk': jt.pk}), user=admin, expect=201)
|
||||
assert response.status_code == 201
|
||||
# set project to not update on launch and validate still 400's
|
||||
project.update_fields(scm_update_on_launch=False)
|
||||
response = post(reverse('api:job_template_launch', kwargs={'pk': jt.pk}), user=admin, expect=400)
|
||||
assert response.status_code == 400
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user