Project

General

Profile

Actions

Bug #10838

closed

File content (Key/value pair) reports for all entries, even if only one changes

Added by Janos Mattyasovszky over 7 years ago. Updated over 6 years ago.

Status:
Rejected
Priority:
N/A
Assignee:
-
Category:
Techniques
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:
43
Name check:
Fix check:
Regression:

Description

When you have one instance of "File content (key/value)" applied to the same file, it reports "repaired" for all managed keys, even if only one was changed.

Test:
Ensure k1=v1, k2=v2 and k3=v3 are present in /tmp/testfile:

# rudder agent run -u -q
Rudder agent 4.1.3.release (CFEngine Core 3.10.0)
Node uuid: 22627a92-f07e-4f8d-8bc2-6e0d2f19b669
ok: Rudder agent promises were updated.
Start execution with config [20170602-085821-bc9417f8]

M| State         Technique                 Component                 Key                Message
E| repaired      Common                    Update                                       Policy, tools or configuration library were updated or agent service restarted
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k3 = v3 was repaired
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k1 = v1 was repaired
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k2 = v2 was repaired
[...]

# cat /tmp/testfile
k3=v3
k1=v1
k2=v2

Then add a fourth key=value pair, and update+run:

# rudder agent run -u -q
Rudder agent 4.1.3.release (CFEngine Core 3.10.0)
Node uuid: 22627a92-f07e-4f8d-8bc2-6e0d2f19b669
ok: Rudder agent promises were updated.
Start execution with config [20170602-090359-93d09b1e]

M| State         Technique                 Component                 Key                Message
E| repaired      Common                    Update                                       Policy, tools or configuration library were updated or agent service restarted
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k3 = v3 was repaired
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k4 = v4 was repaired
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k1 = v1 was repaired
E| repaired      Manage keys-values file   File                      /tmp/testfile      The key -> value k2 = v2 was repaired

## Summary #####################################################################
39 components verified in 7 directives
   => 39 components in Enforce mode
      -> 31 compliant
      -> 5 repaired
      -> 3 not-applicable
execution time: 1.87s
################################################################################

# cat /tmp/testfile
k3=v3
k1=v1
k2=v2
k4=v4

Expected is only a repaired message about k4=v4, but instead one gets messages for all promised key=value pairs.


Related issues 2 (0 open2 closed)

Has duplicate Rudder - Bug #11129: Using of two "File ensure key value in parameter list" methods in the same technique causes the second one to report failed if the first one fails.RejectedActions
Is duplicate of Rudder - User story #12414: Make reporting work when targeting several time the same item with several generic methodReleasedAlexis MoussetActions
Actions #1

Updated by François ARMAND over 7 years ago

Hum, thanks for reporting. That's intersting...

Actions #2

Updated by Janos Mattyasovszky over 7 years ago

  • Description updated (diff)
Actions #3

Updated by François ARMAND over 7 years ago

  • Priority changed from 0 to 17
Actions #4

Updated by Benoît PECCATTE over 7 years ago

  • Priority changed from 17 to 32
Actions #5

Updated by Janos Mattyasovszky over 7 years ago

  • Has duplicate Bug #11129: Using of two "File ensure key value in parameter list" methods in the same technique causes the second one to report failed if the first one fails. added
Actions #6

Updated by Janos Mattyasovszky over 7 years ago

The issue is caused by using rudder_common_reports_generic_index, it is called with:

rudder  verbose: B: BEGIN bundle rudder_common_reports_generic_index( {"Manage keys-values file","file_ensure_key_value__tmp_keyvalue","7dc8baf5-cc40-48e3-a4d4-7b9984da8753@@8514801a-76e2-4318-8be1-85b1d307ba9c@@0","File","/tmp/keyvalue","The key -> value c = 3","3"})

However, the problem is, that the outcome is only defined by the class-prefix, which does not include which key-value pair you edited, only the canonized file as the lowest denominator:

bundle agent rudder_common_reports_generic_index(technique_name, class_prefix,  ... );

[...]

      "repaired" 
        usebundle  => rudder_common_report_index("${technique_name}", "result_repaired",
 "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was repair
ed", "${index}"),
        ifvarclass => "${class_prefix}_repaired.!${class_prefix}_error";   <========= class_prefix contains "file_ensure_key_value__tmp_keyvalue", which is identical for all key-value pairs in this file.

This is because n the file manage-key-value-file.st/cf you use this mapping to define the class_prefix:

    "canonified_file[${index}]"      string => canonify("${file[${index}]}");
    "class_prefix_${index}"          string => "file_ensure_key_value_${canonified_file[${index}]}";

This is not correct, since you are missing the _${index} as suffix to define which key-value you have actually repaired/kept.

However, apparently that would require changing bundle file_ensure_key_value for old_class_prefix to also include "key", which would break compatibility I presume.

I am interested on how you plan to fix this :-/

Actions #7

Updated by Benoît PECCATTE over 7 years ago

  • Severity changed from Minor - inconvenience | misleading | easy workaround to Major - prevents use of part of Rudder | no simple workaround
  • Priority changed from 32 to 51
Actions #8

Updated by Benoît PECCATTE about 7 years ago

  • Priority changed from 51 to 48
Actions #9

Updated by Nicolas CHARLES over 6 years ago

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

This has been fixed in #12414, closing

Actions #10

Updated by Nicolas CHARLES over 6 years ago

  • Is duplicate of User story #12414: Make reporting work when targeting several time the same item with several generic method added
Actions

Also available in: Atom PDF