ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.06k stars 3.42k forks source link

Workflow_template to return a subset list of job templates that were part of it #13557

Open indirakas opened 1 year ago

indirakas commented 1 year ago

Please confirm the following

Feature type

New Feature

Feature Summary

Can you please return more fields with the workflow_jobs get - job ids of subset job templates ids that were part of this workflow template? Currently I get these fields:

{
     "id": 766725,
     "type": "workflow_job",
     "url": "/api/v2/workflow_jobs/766725/",
     "summary_fields": {
          "organization": {
               "id": 4,
               "name": "Networking",
               "description": ""
          },
          "inventory": {
               "id": 4,
               "name": "prod",
               "description": "Production Devices",
               "has_active_failures": false,
               "total_hosts": 334,
               "hosts_with_active_failures": 0,
               "total_groups": 16,
               "has_inventory_sources": true,
               "total_inventory_sources": 1,
               "inventory_sources_with_failures": 0,
               "organization_id": 4,
               "kind": ""
          },
          "workflow_job_template": {
               "id": 438,
               "name": "Failed hosts workflow",
               "description": ""
          },
          "unified_job_template": {
               "id": 438,
               "name": "Failed hosts workflow",
               "description": "",
               "unified_job_type": "workflow_job"
          },
          "created_by": {
               "id": 7,
               "username": "foo",
               "first_name": "Indira",
               "last_name": "K"
          },
          "modified_by": {
               "id": 7,
               "username": "foo",
               "first_name": "Indira",
               "last_name": "K"
          },
          "user_capabilities": {
               "delete": true,
               "start": true
          },
          "labels": {
               "count": 0,
               "results": []
          }
     },
     "created": "2023-02-10T22:10:18.850343Z",
     "modified": "2023-02-10T22:10:19.305410Z",
     "name": "Failed hosts workflow",
     "description": "",
     "unified_job_template": 438,
     "launch_type": "manual",
     "status": "successful",
     "failed": false,
     "started": "2023-02-10T22:10:19.301606Z",
     "finished": "2023-02-10T22:10:36.209895Z",
     "canceled_on": null,
     "elapsed": 16.908,
     "job_args": "",
     "job_cwd": "",
     "job_env": {},
     "job_explanation": "",
     "result_traceback": "",
     "workflow_job_template": 438,
     "extra_vars": "{\"commit_message\": \"test\"}",
     "allow_simultaneous": false,
     "job_template": null,
     "is_sliced_job": false,
     "inventory": 4,
     "limit": "albq-cr6",
     "scm_branch": null,
     "webhook_service": "",
     "webhook_credential": null,
     "webhook_guid": ""
}

Select the relevant components

Steps to reproduce

awx --conf.host https://tower.es.net --conf.username foo --conf.password "bar" workflow_jobs get 766725

Current results

{ "id": 766725, "type": "workflow_job", "url": "/api/v2/workflow_jobs/766725/", "summary_fields": { "organization": { "id": 4, "name": "Networking", "description": "" }, "inventory": { "id": 4, "name": "prod", "description": "Production Devices", "has_active_failures": false, "total_hosts": 334, "hosts_with_active_failures": 0, "total_groups": 16, "has_inventory_sources": true, "total_inventory_sources": 1, "inventory_sources_with_failures": 0, "organization_id": 4, "kind": "" }, "workflow_job_template": { "id": 438, "name": "Failed hosts workflow", "description": "" }, "unified_job_template": { "id": 438, "name": "Failed hosts workflow", "description": "", "unified_job_type": "workflow_job" }, "created_by": { "id": 7, "username": "foo", "first_name": "Indira", "last_name": "K" }, "modified_by": { "id": 7, "username": "foo", "first_name": "Indira", "last_name": "K" }, "user_capabilities": { "delete": true, "start": true }, "labels": { "count": 0, "results": [] } }, "created": "2023-02-10T22:10:18.850343Z", "modified": "2023-02-10T22:10:19.305410Z", "name": "Failed hosts workflow", "description": "", "unified_job_template": 438, "launch_type": "manual", "status": "successful", "failed": false, "started": "2023-02-10T22:10:19.301606Z", "finished": "2023-02-10T22:10:36.209895Z", "canceled_on": null, "elapsed": 16.908, "job_args": "", "job_cwd": "", "job_env": {}, "job_explanation": "", "result_traceback": "", "workflow_job_template": 438, "extra_vars": "{\"commit_message\": \"test\"}", "allow_simultaneous": false, "job_template": null, "is_sliced_job": false, "inventory": 4, "limit": "albq-cr6", "scm_branch": null, "webhook_service": "", "webhook_credential": null, "webhook_guid": "" }

Sugested feature result

Something like this to be reported back:

     "visualizer": [
          "job_template": {
               "id": 766726,
               "name": "Failed-hosts",
               "type": job,
               "status": "failed",
               "created": "2023-02-10T22:10:19.4578",
               "elapsed": "4.371"
          },
          "job_template": {
               "id": 766729,
               "name": "Failed-hosts-part2 ",
               "type": job,
               "status": "successful",
               "created": "2023-02-10T22:10:28.1055",
               "elapsed": "4.141"
          }
     ]

The workflow 766725 consisted of these 2 job templates: 766726 and 766729.

Additional information

No response

AlanCoding commented 1 year ago

I would implore you to consider that this is not the right place for this information. This is obtained by the UI when the user navigates to the basic JOBS list, which is not intending to show a full visualizer of every workflow job that is a part of that list. Already, only a tiny sliver of the data the API returns is actually used to put information list the list views.

Related endpoints tend to be the best kind of solution for this, like /api/v2/workflow_jobs/42/visualizer/. The UI gets the node endpoints directly (to the best of my memory), but it would, itself, find it more convenient to use a special-purpose view that returns everything that's needed and doesn't paginate.

indirakas commented 1 year ago

/api/v2/workflow_jobs/42 works, but /api/v2/workflow_jobs/42/visualizer/ returns { "detail": "The requested resource could not be found." }