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.1k stars 3.43k forks source link

Cleanup Job Details. Configure days retention for the particular job entities. #14384

Open elibogomolnyi opened 1 year ago

elibogomolnyi commented 1 year ago

Please confirm the following

Feature type

Enhancement to Existing Feature

Feature Summary

For now, in the management job Cleanup Job Schedule, we can only define the number of days for all job-related entities, including ad-hoc commands, project-updates, inventory-updates, management-jobs, notifications, and workflow jobs.

image

It would be very useful to make it configurable to define a different number of days for different entities.

For example, we need the job history for 90 days. Still, we don't need the notification history since we use notifications only for sending our logs to DataDog and don't use them anymore.

It can be done by using the awx-manage cli by command: awx-manage cleanup_jobs --notifications --days 0

But we didn't find a way to do it from AWX UI by configuring the Management jobs, so we won't need to create an additional cronjob in K8s that will do it.

Select the relevant components

Steps to reproduce

Run cleanup for jobs that are older than 90 days.

Current results

All job-related entities were deleted.

Sugested feature result

Only particular job-related entities are deleted; the number of days is configurable for each type of job.

Additional information

No response

fosterseth commented 1 year ago

currently the UI adds this payload to the system job launch endpoint {"extra_vars":{"days":30}} so we'd need to change the api to accept a new param like "resources" {"extra_vars":{"days": 30, "resources":["notifications", "jobs"]}} something like that. Then we would change this line to only pass those resources https://github.com/fosterseth/awx/blob/bb1c155bc91505f89d7074820424eac7d7072c4d/awx/main/tasks/jobs.py#L1880

erz4 commented 1 year ago

currently the UI adds this payload to the system job launch endpoint {"extra_vars":{"days":30}} so we'd need to change the api to accept a new param like "resources" {"extra_vars":{"days": 30, "resources":["notifications", "jobs"]}} something like that. Then we would change this line to only pass those resources https://github.com/fosterseth/awx/blob/bb1c155bc91505f89d7074820424eac7d7072c4d/awx/main/tasks/jobs.py#L1880

@fosterseth what about that function? https://github.com/ansible/awx/blob/1bb4240a6ba9b92043cb410585a95f3bf20d89bf/awx/main/management/commands/cleanup_jobs.py#L379

fosterseth commented 1 year ago

The awx-manage command already has the capabilities to delete specific resources, so we probably don't need changes in that file. The change needed here it so be able to specify these extra parameters in the API