Bug #10838
closedFile content (Key/value pair) reports for all entries, even if only one changes
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.
Updated by François ARMAND over 7 years ago
Hum, thanks for reporting. That's intersting...
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
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 :-/
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
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
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