Job cancellation

22 views
Skip to first unread message

avi haim

unread,
Sep 20, 2023, 2:36:31 PM9/20/23
to Salt-users
Is there a way to cancel a job by ‘jobid’, When the job enters the queue and has not yet reached the minion\minions.
Im using salt rest api (cherry)

Rodrigo Moutinho (rcmoutinho)

unread,
Sep 25, 2023, 12:26:57 PM9/25/23
to Salt-users
Hello!

You can use the module/function: saltutil.kill_job <job id>
Here is the docs reference: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.saltutil.html#salt.modules.saltutil.kill_job

Cheers!

avi haim

unread,
Sep 27, 2023, 3:44:37 AM9/27/23
to salt-...@googlegroups.com
thanks a lot for the answer,
As far as I understand, this model knows how to cancel a job in a minion.
He does not know how to cancel a job at the salt master level.
My goal is to cancel the job before it reaches the minions.

‫בתאריך יום ב׳, 25 בספט׳ 2023 ב-19:26 מאת ‪Rodrigo Moutinho (rcmoutinho)‬‏ <‪rcm...@gmail.com‬‏>:‬
--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/AZ4Z3bgxK4c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/c719ffe4-fd7c-4715-9ac5-ea659e27b6can%40googlegroups.com.

Rodrigo Moutinho (rcmoutinho)

unread,
Sep 27, 2023, 6:14:27 PM9/27/23
to Salt-users
Hello!

You can do it directly on the minion or from the server. If you are on the salt server, you can do something like the docs mention: "salt <target> saltutil.kill_job <job id>".

Doing it before entering the queue or being executed might be tricky, depending on your scenario.
Salt is built to be extremely fast with ZeroMQ (as mentioned in these docs: https://docs.saltproject.io/en/latest/topics/development/topology.html, and many others). If you have a very intense salt server, it might take longer to process, but it would still be fast. Or if your execution is too long, you could cancel the rest of the process at least.

If you are worried about the side effects of your implementation, you should use show_sls (https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.state.html#salt.modules.state.show_sls) so you can see the execution map or test=True to execute the state but not apply any change.
In case you are executing direct module calls, this would be harder to predict and also cancel due to the fast execution most of the time.

I hope it helps.
Cheers!

PS: There are some projects like SaltGUI, https://github.com/erwindon/SaltGUI, that might help you do this from a UI level, potentially doing it faster than usual (because finding the job ID can be tricky depending on the scenario). If you are already dealing with REST API, it won't be that hard to make it work on your side.
Reply all
Reply to author
Forward
0 new messages