Architecture #15783
closedUser story #6099: We should be able to call actions as many times as we want
Make class_prefix unique
Description
With the technique editor, the big idea is to define techniques that can be decline in multiple directives.
One of the problem is: if we have the same call made to a generic method, it will most likely be ignored at execution time by cfengine. Leading to broken reporting and
no easy way to properly what was executed on the system.
Since in Rudder, one directive is ALWAYS bond to only one technique, we could use the directive_id as key differentiator between each policy applied.
Which means that every call to a rudder logger or pure cfengine promise should be followed by a comment based on the directive id.
See:
commands: "${command}" contain => in_shell, classes => classes_generic_return_code_list_two("${old_class_prefix}", "${class_prefix}", @{kept_list}, @{repaired_list}), comment => "${report_data.directive_id}";
And
usebundle => _log_v3("Execute the command ${command}", "${command}", "${old_class_prefix}", "${class_prefix}", @{args}), comment => "${report_data.directive_id}";
This way every directive will be forced to execute its promises and reports on it, even if the exact same one was already evaluated sooner in the process.
But every exact same call will produce classes based on the same element which make reporting undoable. To avoid this we should also base the resulting classes
of each GM on the directive id .
Where:
"old_class_prefix" string => canonify("command_execution_result_${command}"); "args" slist => { "${command}", "${kept_codes}", "${repaired_codes}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("command_execution_result_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000");
will become:
"old_class_prefix" string => canonify("${report_data.canonified_directive_id}_command_execution_result_${command}"); "args" slist => { "${command}", "${kept_codes}", "${repaired_codes}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("${report_data.canonified_directive_id}_command_execution_result_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000");