mirror of
https://github.com/ansible/awx.git
synced 2026-07-10 15:58:05 -02:30
Allow deleting org of a running workflow job (#15374)
Old RBAC system hits DOESNOTEXIST query errors if a user deletes an org while a workflow job is active. The error is triggered by 1. starting workflow job 2. delete the org that the workflow job is a part of 3. The workflow changes status (e.g. pending to waiting) This error message would surface awx.main.models.rbac.Role.DoesNotExist: Role matching query does not exist. The fix is wrap the query in a try catch, and skip over some logic if the roles don't exist. --------- Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
@@ -48,3 +48,17 @@ def test_org_resource_role(ext_auth, organization, rando, org_admin):
|
||||
assert access.can_attach(organization, rando, 'member_role.members') == ext_auth
|
||||
organization.member_role.members.add(rando)
|
||||
assert access.can_unattach(organization, rando, 'member_role.members') == ext_auth
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_delete_org_while_workflow_active(workflow_job_template):
|
||||
'''
|
||||
Delete org while workflow job is active (i.e. changing status)
|
||||
'''
|
||||
assert workflow_job_template.organization # sanity check
|
||||
wj = workflow_job_template.create_unified_job() # status should be new
|
||||
workflow_job_template.organization.delete()
|
||||
wj.refresh_from_db()
|
||||
assert wj.status != 'pending' # sanity check
|
||||
wj.status = 'pending' # status needs to change in order to trigger workflow_job_template.save()
|
||||
wj.save(update_fields=['status'])
|
||||
|
||||
Reference in New Issue
Block a user