Project

General

Profile

Actions

Bug #13894

closed

ncf technique can trigger every cfengine pass and break their reporting in specifics cases

Added by Félix DALLIDET about 6 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
N/A
Assignee:
-
Category:
Generic methods
Target version:
Severity:
Major - prevents use of part of Rudder | no simple workaround
UX impact:
User visibility:
Effort required:
Small
Priority:
0
Name check:
Fix check:
Regression:

Description

See in the Rudder training:

In the technique editor, set a variable to a numerical value
multiply it by 4 and stores it in the same variable
make a condition on its content
write different messages in a file depending on the previous condition defined.

The math expressions was executed multiple time.
I guess that cfengine execute it in each pass since the variable is rewritten.
Forcing the calcul to the last pass could help if it is not already done.


Related issues 1 (0 open1 closed)

Related to Rudder - Bug #13877: using mustache templating with the wrong syntax can lead to broken cfengineRejectedAlexis MoussetActions
Actions #1

Updated by Félix DALLIDET about 6 years ago

Problem has nothing to do with the generic method in itself.
In the ncf technique generated by the technique we have:

    "method_call" usebundle => variable_string_from_math_expression("my_math", "variable1", "${my_math.variable1}*4", "%d"),
      ifvarclass => concat("any");

But Since "${my_math.variable1}*4" will change value after each execution of the line, the "variable_string_from_math_expression" will be call
in each pass of cfengine.

Still, this break the reporting for unknown reasons

Actions #2

Updated by Félix DALLIDET about 6 years ago

At execution, the method_call_context_ is not reevalued, and so, only the method_call_context_ for the command execution was executed.

=> We should force the technique editor techniques to execute only the pass1.

# @name testing math stuff
# @description 
# @version 1.0

bundle agent testing_math_stuff
{
  methods:
    "method_call_context_0" usebundle => _method_reporting_context("Variable string", "variable1");
    "method_call" usebundle => variable_string("my_math", "variable1", "256"),
      ifvarclass => concat("any");
    "method_call_context_1" usebundle => _method_reporting_context("Variable string from math expression", "variable1");
    "method_call" usebundle => variable_string_from_math_expression("my_math", "variable1", "${my_math.variable1}*4", "%d"),
      ifvarclass => concat("any");
    "method_call_context_2" usebundle => _method_reporting_context("Condition from variable match", "ok_var");
    "method_call" usebundle => condition_from_variable_match("ok_var", "math.math", "1024"),
      ifvarclass => concat("any");
    "method_call_context_3" usebundle => _method_reporting_context("Command execution", "echo '${my_math.variable1} equals 1024' > /tmp/result"),
    "method_call" usebundle => command_execution("echo '${my_math.variable1} equals 1024' > /tmp/result"),
      ifvarclass => concat("any.(ok_var_true)");
}

Actions #3

Updated by Félix DALLIDET about 6 years ago

  • Severity set to Major - prevents use of part of Rudder | no simple workaround
  • Effort required set to Small
Actions #4

Updated by Vincent MEMBRÉ about 6 years ago

  • Target version changed from 5.0.3 to 5.0.4
Actions #5

Updated by Félix DALLIDET about 6 years ago

  • Subject changed from variable from math expression can triggers each pass of cfengine at execution time to ncf technique can trigger every cfengine pass and break their reporting in specifics cases
Actions #6

Updated by Benoît PECCATTE about 6 years ago

  • Status changed from New to Rejected

"multiply it by 4 and stores it in the same variable" << never ever do that in cfengine and in Rudder in general.

We must write target state, and x*=4 is not a state.

CFengine does evalate its pass many times assuming that everything targets a stable state. If it's not, many things will break.

Actions #7

Updated by François ARMAND almost 6 years ago

  • Related to Bug #13877: using mustache templating with the wrong syntax can lead to broken cfengine added
Actions #8

Updated by Alexis Mousset over 2 years ago

  • Project changed from 41 to Rudder
  • Category changed from Generic methods to Generic methods
Actions

Also available in: Atom PDF