Project

General

Profile

Actions

Bug #5598

closed

logger_rudder fails on windows

Added by Nicolas CHARLES about 8 years ago. Updated 4 months ago.

Status:
Released
Priority:
1
Category:
Generic methods
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Regression:

Description

And it fails quite bad...

we can canonify with cfengine itself

 vars:

      "log_canonification_tool" string => '/bin/cat "${expected_reports_temp}" | while read line; do if echo "${line}" | grep -E "^\s*#" > /dev/null; then echo "${line}"; continue; fi; canonified=$(echo "${line}" | cut -d";" -f3 | sed "s/[^a-zA-Z0-9_]/_/g"); echo ${line} | sed -r "s/([^;]+);;[^;]+;;(.*)$/\1;;${canonified};;\2/"; done > ${expected_reports_file}';

      "expected_reports_source" string => "${sys.workdir}/inputs/rudder_expected_reports.csv";
      "expected_reports_temp"   string => "${expected_reports_source}.tmp";
      "expected_reports_file"   string => "${expected_reports_source}.res";

    windows.logger_rudder_temp_resfile_repaired::
      # 2/ On windows, we cannot rely on sed and all, so we canonify with CFEngine
      "dim" int => readstringarrayidx("reports", "${expected_reports_temp}", "\s*#[^\n]*", ";;", 9999, 999999);
      "keys" slist => getindices("reports");

      # canonify the first entry
      "reports[${keys}][canon]" string => canonify("${reports[${keys}][1]}");

    (logger_rudder_final_resfile_repaired|logger_rudder_temp_resfile_kept)::

      # 3/ Once the final expected reports file has been expanded, read in our array
      "number_lines" 
        int        => getfields("^[^;]*;;${class_prefix};;.*", "${expected_reports_file}", ";;", "report_data"),
        classes    => if_ok("report_data_read");
 files:
    # 3/ On windows, we create the result file
    logger_rudder_temp_resfile_repaired.windows::
      # first, empty the file
      "${expected_reports_file}" 
        create => "true",
        edit_line => delete_lines_matching(".*");

      # then fill it (we can't use edit_default empty, as we are adding line by line (i don't knwo how to add all at once)
      "${expected_reports_file}" 
        create => "true",
        edit_line => insert_lines("${reports[${keys}][0]};;${reports[${keys}][canon]};;${reports[${keys}][2]};;${reports[${keys}][3]};;${reports[${keys}][4]}"),
        classes       => classes_generic("logger_rudder_final_resfile");

    any::
      # 1/ First, check if the temporary file needs to be updated (The Rudder
      # provided expected reports file has changed). If so, expand the variables
      # in it into a temporary file.
      "${expected_reports_temp}" 
        create        => "true",
        edit_template => "${expected_reports_source}",
        classes       => classes_generic("logger_rudder_temp_resfile");
  commands:

    logger_rudder_temp_resfile_repaired.!windows::

      # 2/ If the temporary file has been updated, trigger this command to canonify all the values in
      # it.
      "${log_canonification_tool}" 
        contain       => in_shell,
        classes       => classes_generic("logger_rudder_final_resfile");


Related issues 2 (0 open2 closed)

Related to Rudder - Bug #5770: logger_rudder don't log anymoreReleasedMatthieu CERDAActions
Has duplicate Rudder - Bug #5555: logger_rudder doesn't properly canonify entriesRejectedJonathan CLARKEActions
Actions #1

Updated by Nicolas CHARLES almost 8 years ago

  • Status changed from New to Pending technical review
  • Assignee set to Jonathan CLARKE
  • Pull Request set to https://github.com/Normation/ncf/pull/129
Actions #2

Updated by Nicolas CHARLES almost 8 years ago

  • Status changed from Pending technical review to Pending release
  • % Done changed from 0 to 100

Applied in changeset commit:ea1b95ec4b2fcfb5e1d9617a0b166f17fa388b02.

Actions #3

Updated by Benoît PECCATTE almost 8 years ago

Applied in changeset commit:898c9883b5b5bc507d3673ee4d34bf24f59225be.

Actions #4

Updated by Vincent MEMBRÉ about 6 years ago

  • Status changed from Pending release to Released
Actions #5

Updated by Alexis Mousset 4 months ago

  • Target version changed from 0.x to ncf-0.x
  • Priority set to 0
Actions #6

Updated by Alexis Mousset 4 months ago

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

Also available in: Atom PDF