Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2109

ifelapsed is not working on all promise types

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Rejected
    • Priority: (None)
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      In the documentation I read that "are available to all promise types":https://docs.cfengine.com/docs/3.6/reference-promise-types.html#common-attributes. Therefore I expected I could use an action attribute to timeout a vars promise that used execresult.

      But that doesn't work. In the following piece of policy:

      body common control
      {
      	  bundlesequence => { "test" } ;
      }
      
      
      bundle agent test
      {
        vars:
            "test"
      	  string => execresult("/bin/pwd","noshell"),
      	  action => if_elapsed("60") ;
      
        classes:
            "var_is_set" expression => isvariable("test") ;
      
        reports:
          var_is_set::
            "variable is set to $(test)" ;
      
          !var_is_set::
            "variable was not set" ;
      }
      
            
      
      body action if_elapsed(x)
      # @brief Evaluate the promise every `x` minutes
      # @param x The time in minutes between promise evaluations
      {
            ifelapsed => "$(x)";
            expireafter => "$(x)";
      }
      

      the variable is assigned at the first run and the promise is locked for just one minute, not 60:

      2015-08-20T19:02:23+0200  verbose: /default/test/reports/'variable is set to /tmp'[0]: XX Nothing promised here [last.test.reports.-murray.variable_is_se] (0/1 minutes elapsed)
      

      and in fact, running the test again after more than one minute works as like the action attribute was not there. Incidentally, that means that any function that spawns a command to set a variable can't be timed out or locked for a certain time using action.

      If this is the expected behavior, the bug is in the documentation.

      If this is not expected behavior, the bug is in the code.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                bronto Marco Marongiu
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel