commands promises sent to background

15 views
Skip to first unread message

tentaculartentacle

unread,
Mar 23, 2017, 1:32:47 PM3/23/17
to help-cfengine
I'd like to find a way to have cfengine wait for some very long commands promises to complete.
In a simplified example, I run a long-running installer and capture the result, and conditionally run something else based on that result:

methods:
  "" usebundle => step1, action => result("bigproduct_installation");
  bigproduct_installation_repaired::
    "" usebundle => step2;

in step1 bundle:
commands:
  "/mnt/horrible_vendor/bigproduct/installer.sh";

Then in step2, I'll do all the product configuration, which really must only be done if the huge ugly installer.sh completely without errors, otherwise I can create a royal mess. There's no practical way to deduce whether it was successful by anything else than the exit code.

Things is, step1 can run for a very long time. It looks like cfengine will give up waiting for commands, and push them to the background, which is fair enough. But it means bigproduct_installation is never going to be "repaired". 

A kind of ugly workaround is something like "installer.sh && touch /tmp/all_done_without_errors" and then use a fileexists("/tmp/all_done_without_errors") to trigger step2.

Is there no way to change the behaviour to let cfengine be exceptionally patient when I want it to? Where is this timeout set? I found exec_timeout, but that doesn't appear to be what i need.


Neil H. Watson

unread,
Mar 23, 2017, 2:19:34 PM3/23/17
to help-cfengine
These may help:
https://docs.cfengine.com/docs/3.7/reference-promise-types.html#expireafter
https://docs.cfengine.com/docs/3.7/reference-promise-types.html#background

I think that making your process into a daemon along with code to manage a
semaphore file would be more reliable.

--
Neil H Watson @neil_h_watson
CFEngine reporting: https://github.com/neilhwatson/delta_reporting
CFEngine policy: https://github.com/neilhwatson/evolve_cfengine_freelib
CFEngine and vim: https://github.com/neilhwatson/vim_cf3
Reply all
Reply to author
Forward
0 new messages