Forum: CFEngine Help Subject: Re: CFEngine Help: Multple (identical) command executions optimized away? Author: nickanderson Link to topic: https://cfengine.com/forum/read.php?3,25778,25781#msg-25781
Yeah, I tested it. It might not be locks but its still the same promise. I consider this is correct behavior. You have to have something to differentiate promises from each-other. You are doing that with your use of classes. It could also be done with the use of handle Here is a longer contrived example. You can see that there are 9 promises but only 7 are actually different. The 8th is a duplicate of the 5th, and the 9th is a duplicate of the third. But as long as something is different then each promise is recognized as an individual promise. If you look in the verbose output you can see two messages where "This promise has already been verified". Maybe it would be helpful if it showed the line number there or a promise handle by what was already verified. Does this make more sense? body common control { bundlesequence => { "main", }; inputs => { "cfengine_stdlib.cf", }; } bundle agent main { commands: "/bin/true" action => if_elapsed("1"); "/bin/true" action => if_elapsed("0"); "/bin/true" handle => "third"; "/bin/true" handle => "fourth"; # 5th "/bin/true"; "/bin/true" comment => "sixth"; "/bin/true" comment => "seventh"; # Duplicate of 5th "/bin/true"; # Duplicate of third "/bin/true" handle => "third"; } # Inform mode run cf-agent -KIf ./test_locks.cf -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /bin/true # Count number of executions cf-agent -KIf ./test_locks.cf | grep -c Executing 7 # Verbose run snippet cf-agent -KIvf ./test_locks.cf cf3> ......................................................... cf3> Promise's handle: cf3> Promise made by: "/bin/true" cf3> cf3> Comment: seventh cf3> ......................................................... cf3> cf3> -> Executing '/bin/true' ...(timeout=-678,owner=-1,group=-1) cf3> -> (Setting umask to 77) cf3> -> Finished command related to promiser "/bin/true" -- succeeded cf3> -> Completed execution of /bin/true cf3> -> Promiser string contains a valid executable (/bin/true) - ok cf3> -> This promise has already been verified cf3> -> Promiser string contains a valid executable (/bin/true) - ok cf3> -> This promise has already been verified _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine