Project

General

Profile

Actions

Bug #23925

closed

Parameters are not properly intepreted in method call conditions

Added by Félix DALLIDET about 1 year ago. Updated 11 months ago.

Status:
Released
Priority:
N/A
Category:
rudderc
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
Error - Next version
Regression:
No

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.


Related issues 1 (1 open0 closed)

Related to Rudder - Bug #24106: Message is not correct when conditions are not met, when using variables in conditionNewActions
Actions #1

Updated by Félix DALLIDET about 1 year ago

  • Status changed from New to In progress
  • Assignee set to Félix DALLIDET
Actions #2

Updated by Félix DALLIDET about 1 year 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
Actions #3

Updated by Félix DALLIDET about 1 year ago

  • Status changed from Pending technical review to Pending release
Actions #4

Updated by Vincent MEMBRÉ 11 months ago

  • Subtask #24106 added
Actions #5

Updated by Vincent MEMBRÉ 11 months ago

  • Subtask deleted (#24106)
Actions #6

Updated by Vincent MEMBRÉ 11 months ago

  • Related to Bug #24106: Message is not correct when conditions are not met, when using variables in condition added
Actions #7

Updated by Vincent MEMBRÉ 11 months ago

  • Fix check changed from To do to Error - Next version
Actions #8

Updated by Vincent MEMBRÉ 11 months ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 8.0.5 which was released today.

Actions

Also available in: Atom PDF