Bug #23925
closedParameters are not properly intepreted in method call conditions
Description
The techniques parameters are not defined globally in the technique and so, expressions resolved outside of the bundles and containing a technique parameter reference are never evaluated.
See the technique.cf below:
# @name hfjakhf
# @version 1.0
bundle agent hfjakhf(file) {
vars:
"args" slist => {"${file}"};
"report_param" string => join("_", args);
"full_class_prefix" string => canonify("hfjakhf_${report_param}");
"class_prefix" string => string_head("${full_class_prefix}", "1000");
methods:
"9e763779-9f33-44bc-ad73-1c5d5732301c_${report_data.directive_id}" usebundle => call_hfjakhf_9e763779_9f33_44bc_ad73_1c5d5732301c("File check exists", "/tmp/${file}", "9e763779-9f33-44bc-ad73-1c5d5732301c", @{args}, "${class_prefix}", "/tmp/${file}");
"e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => call_hfjakhf_e8362340_dc50_4231_9b7f_748b51e9fa07("Command execution", "echo \"oui\"", "e8362340-dc50-4231-9b7f-748b51e9fa07", @{args}, "${class_prefix}", "echo \"oui\"");
}
bundle agent call_hfjakhf_9e763779_9f33_44bc_ad73_1c5d5732301c(c_name, c_key, report_id, args, class_prefix, path) {
methods:
"9e763779-9f33-44bc-ad73-1c5d5732301c_${report_data.directive_id}" usebundle => _method_reporting_context_v4("${c_name}", "${c_key}", "${report_id}");
"9e763779-9f33-44bc-ad73-1c5d5732301c_${report_data.directive_id}" usebundle => file_check_exists("${path}");
}
bundle agent call_hfjakhf_e8362340_dc50_4231_9b7f_748b51e9fa07(c_name, c_key, report_id, args, class_prefix, command) {
methods:
"e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => _method_reporting_context_v4("${c_name}", "${c_key}", "${report_id}");
"e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => command_execution("${command}"),
if => concat("file_check_exists__tmp_",canonify("${file}"),"_kept");
"e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => _classes_noop(canonify("${class_prefix}_command_execution_${c_key}")),
unless => concat("file_check_exists__tmp_",canonify("${file}"),"_kept");
"e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => log_rudder("Skipping method 'Command execution' with key parameter 'echo \"oui\"' since condition 'file_check_exists__tmp_${file}_kept' is not reached", "echo \"oui\"", canonify("${class_prefix}_command_execution_${c_key}"), canonify("${class_prefix}_command_execution_${c_key}"), @{args}),
unless => concat("file_check_exists__tmp_",canonify("${file}"),"_kept");
}
Generated from:
id: hfjakhf
name: hfjakhf
version: '1.0'
category: ncf_techniques
params:
- id: 2f415dc5-9f9e-4fbe-b836-8960af613ec9
name: file
description: file
constraints:
allow_empty: false
items:
- id: 9e763779-9f33-44bc-ad73-1c5d5732301c
name: ''
method: file_check_exists
params:
path: /tmp/${hfjakhf.file}
- id: e8362340-dc50-4231-9b7f-748b51e9fa07
name: ''
condition: file_check_exists__tmp_${hfjakhf.file}_kept
method: command_execution
params:
command: echo "oui"
The expression unless => concat("file_check_exists__tmp_",canonify("${file}"),"_kept"); will never be checked as the file variable is not exposed here. It should instead use the long variable name hfjakhf.file.
A quick workaround is to replace any parameter call in expression with their fully qualified name.
This issue is most likely also impacting expressions refering to the resource_dir variable.
Updated by Félix DALLIDET over 2 years ago
- Status changed from New to In progress
- Assignee set to Félix DALLIDET
Updated by Félix DALLIDET over 2 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from Félix DALLIDET to Alexis Mousset
- Pull Request set to https://github.com/Normation/rudder/pull/5270
Updated by Félix DALLIDET over 2 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset rudder|503987eefcdfeec0a8961d744fc9b0e5aa2978c2.
Updated by Vincent MEMBRÉ over 2 years ago
- Subtask #24106 added
Updated by Vincent MEMBRÉ over 2 years ago
- Subtask deleted (
#24106)
Updated by Vincent MEMBRÉ over 2 years ago
- Related to Bug #24106: Message is not correct when conditions are not met, when using variables in condition added
Updated by Vincent MEMBRÉ over 2 years ago
- Fix check changed from To do to Error - Next version
Updated by Vincent MEMBRÉ over 2 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 8.0.5 which was released today.