Project

General

Profile

Actions

Bug #8572

closed

Report "missing" on directive using json variable

Added by Arnaud ANDRE almost 8 years ago. Updated almost 5 years ago.

Status:
Rejected
Priority:
N/A
Assignee:
-
Category:
Web - Compliance & node report
Target version:
-
Severity:
Major - prevents use of part of Rudder | no simple workaround
UX impact:
User visibility:
Operational - other Techniques | Technique editor | Rudder settings
Effort required:
Priority:
0
Name check:
Fix check:
Regression:

Description

Hello,

After executing successfully directive using variable loaded from "CFEngine variable definition using a JSON file" technique, the report is "missing".

The directive is"echo ${corp.admin_infra[username]} > /tmp/admin_infra", corp.admin_infra is loaded from a json file.

It seems that the value of ${corp.admin_infra[username]} is not known at the generation of the report (${reports[ 2][canon]} in rudder_exepected_reports.csv.res) :

cat /var/rudder/cfengine-community/inputs/rudder_expected_reports.csv

# Format: technique_name;;class_prefix_${key};;@@RUDDER_ID@@;;component name;;component key
dump_admin_infra;;command_execution_echo ${corp.admin_infra[username]} > /tmp/admin_infra;;beac8ec7-4d2a-4844-abce-929b6c5eb1f7@@366717a1-2c5a-4aa8-b4e6-dbeef5de175c@@36;;Command execution;;echo ${corp.admin_infra[username]} > /tmp/admin_infra

cat /var/rudder/cfengine-community/inputs/rudder_expected_reports.csv.res
dump_admin_infra;;${reports[2][canon]};;beac8ec7-4d2a-4844-abce-929b6c5eb1f7@@366717a1-2c5a-4aa8-b4e6-dbeef5de175c@@36;;Command execution;;echo ${corp.admin_infra[username]} > /tmp/admin_infra;;${reports[2][5]};;${reports[2][6]}
Uninstall_vmware_tools;;command_execution__usr_bin_vmware_uninstall_tools_pl;;beac8ec7-4d2a-4844-abce-929b6c5eb1f7@@ac2e3d5f-4843-4f12-b540-6e6c19850b04@@36;;Command execution;;/usr/bin/vmware-uninstall-tools.pl;;${reports[1][5]};;${reports[1][6]}
Uninstall_vmware_tools;;condition_from_command_vmware_tools;;beac8ec7-4d2a-4844-abce-929b6c5eb1f7@@ac2e3d5f-4843-4f12-b540-6e6c19850b04@@36;;Condition from command ;;vmware-tools;;${reports[0][5]};;${reports[0][6]}

Thanks,

Actions #1

Updated by Nicolas CHARLES almost 8 years ago

Hi arnaud,

I reproduced the issue - I don't understand yet why it happens, I'm working on it.

Actions #2

Updated by Nicolas CHARLES almost 8 years ago

This is a really interesting bug.
Here the issue is that "${corp.admin_infra[username]}" is not yet defined when the ncf logs are computed.
ncf logs are computed at the first call of a generic methods, after promises are generated. So we have two blocking points here:
  1. first time directive is created, the file is not downloaded, so the variable cannot be read, so it has no value
  2. at next policy generation, the json file is downloaded, so it could read it. BUT the directive variableFromJsonFile first calls generic method "directory_create", creating all the logs for ncf. The variable wasn't read yet - it can't be used for reporting

So, in a nutshell, with current implementation, we can't report in techniques made with the Technical Editor with json variables created in variable from json file

Actions #3

Updated by Nicolas CHARLES almost 8 years ago

After discussing with Benoît, we arrived at a working solution (in theory)
The idea would be to stop evaluating the canonified variable at the start of the run, so basically keeping only the .tmp file
At log execution, we would read all reports for the current_technique_report_info (with the benefit of having it done only once per technique, rather than once per report, so maybe a perf improvement), and extract the lines that match the passed canonified class

So we don't have the issue of early/late evaluation: reports using variables are evaluated when they are used

Actions #4

Updated by Benoît PECCATTE about 7 years ago

  • User visibility set to Operational - other Techniques | Technique editor | Rudder settings
Actions #5

Updated by François ARMAND about 7 years ago

  • Severity set to Major - prevents use of part of Rudder | no simple workaround
Actions #6

Updated by Jonathan CLARKE about 7 years ago

It seems it would make sense to run all "Variable " loading Techniques *before other directives.

Actions #7

Updated by Benoît PECCATTE about 7 years ago

  • Priority set to 31
Actions #8

Updated by Benoît PECCATTE almost 7 years ago

  • Priority changed from 31 to 30
Actions #9

Updated by Benoît PECCATTE almost 7 years ago

  • Priority changed from 30 to 43
Actions #10

Updated by Nicolas CHARLES almost 5 years ago

  • Status changed from New to Rejected
  • Priority changed from 43 to 0

This was because of the way reporting was done in pre-5.0. We don't have the csv file anymore, so it's working as expected now

Actions

Also available in: Atom PDF