Delete all Requests in Queue

General Situation:
We have several ruby scripts that are part of state machines. These custom scripts seem to have a bug that doesn’t allow them to finish (endless loop inside). We are seeing these tasks run on for too long. This was a script that is part of hundreds of currently running/still visible requests.

We have found that deleting the request via the UI stops this behaviour. Is there a programatic way to delete/cancel all requests to allow us to clean the queue, revise the broken code, and start over?

Have tried a POST to /api/requests/:id with the cancel action and those failed.

Would go into the DB and see if I can remove them there, but would that break any request cleanup the “Delete” button does?

Thanks in advance.

You might want to try deleting the tasks via the API, rather than the requests:

https://www.manageiq.org/docs/reference/latest/api/reference/tasks.html#deleting-tasks

caveat: I’ve never tried this way of cancelling a running task - good luck :slight_smile:

pemcg

Thanks Peter,

I did investigate this as well but I have no idea which tasks tie to which request without maybe alot of logic. I am surprised the API doesnt have the same functionality the web UI has to delete a request. I’ll keep searching.

From the API, if you call something like:

/api/requests/<id>?attributes=id,description,miq_request_tasks

you’ll get the list of tasks associated with that request ID, for example:

{
    "href": "https://<ip>/api/requests/40",
    "id": "40",
    "description": "Provisioning Service [RHEL 7 VM] from [RHEL 7 VM]",
    "miq_request_tasks": [
        {
            "href": "https://<ip>/api/request_tasks/60",
            "id": "60",
            "description": "Provisioning VM [pemcg-rhel7-template-master] for Service [pemcg-rhel7-template-master]",
            "state": "finished",
            "request_type": "clone_to_service",
            "userid": "admin",
            "options": {
                "dialog": {
                    "request": "clone_to_service",
                    "Service::Service": 31
                },

pemcg

Thanks!, I will give that a try and see how it goes.