Parallel Foreman/Katello API calls are not ordered / do not have dependencies

Hello community!
I’ve written an tool for automating the patch workflow of Foreman/Katello and one of my scripts triggers a VM reboot call after sending a request to update packages on Katello hosts.
I stumbled upon the effect a reboot is triggered while Katello updates packages on a particular host. The result is that installing patches never finishes as the VM is rebooted during installation.

I confirmed this behavior on Foreman 1.19 and Katello 3.8 - I’m pretty sure that this was working under Katello 3.6.

My question is: is this a bug? I’d expect that multiple requests (install errata, install package update, reboot VM) committed sequentially have dependencies (execute A and B before C).

Thank you very much for any ideas in advance!

Problem:
Multiple API requests committed sequentially do not have dependencies

Expected outcome:
Multiple API requests committed sequentially have a clear sequence - e.g.: execute A, B and finally C.

Foreman and Proxy versions:
Foreman 1.19.0
katello 3.8
bastion 6.1.11
foreman-tasks 0.13.4
foreman_cockpit 2.0.3
foreman_docker 4.1.0
foreman_remote_execution 1.5.6

Other relevant data:
My tool triggers the following API calls sequentially:

PUT /api/v2/hosts/$id/errata/apply
PUT /api/v2/hosts/$id/power (payload: {"power_action": "soft"})

I would not call this a bug, For any API that kicks off an async task, tools need to wait for that async task to finish before performing a subsequent action.

1 Like

Hey @ehelms,
thanks for the feedback!

So the solution would be to poll from my application in order to check whether the task has finished prior to triggering the reboot? Or is there a way to queue sync tasks?

Best wishes,
Christian.

You’ll want to poll the task until it is complete and then kickoff your reboot.

1 Like

Thanks for the feedback!
So, I will implement a kind of polling in my utility.

Best wishes,
Christian.