Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #22088: make iterator report more independent #1375

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions tree/20_cfe_basics/common.cf
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ body classes cancel_classes(y)
"repair_denied_$(y)", "$(y)_denied", "repair_timeout_$(y)",
"$(y)_timeout", "promise_kept_$(y)", "$(y)_kept"
};

}

body classes common_classes_exclusive_persist_codes(prefix, persist, keptcodes, repairedcodes, errorcodes)
Expand Down Expand Up @@ -353,7 +353,7 @@ bundle agent ncf_classes_copy(source_prefix, destination_prefix)
"destination_defined" expression => strcmp("${destination_prefix}", "${destination_prefix}");
"destination_not_empty" not => strcmp("${destination_prefix}", "");
"destination_exists" and => { "destination_defined", "destination_not_empty" };

"pass2" expression => "pass1";
"pass1" expression => "any";
}
Expand Down Expand Up @@ -381,7 +381,7 @@ bundle agent call_method(method) {
# needs to be called in pass3 as it changes the report_data.method_id which makes it reexecute
"${report_data.method_id}" usebundle => method_id_push("${method}");
"${report_data.method_id}" usebundle => disable_reporting;

reports:
pass3.debug::
"${configuration.debug} Entering method ${report_data.method_id} (should_report: ${call_method_data.${method_id}_${method}})";
Expand All @@ -392,7 +392,7 @@ bundle agent call_method_classes(copy_to_prefix) {
"prefix" string => canonify("${copy_to_prefix}");

methods:
"${report_data.method_id}" usebundle => _classes_copy("${report_data.method_id}", "${prefix}");
"${report_data.method_id}" usebundle => _classes_copy("${report_data.report_id}", "${prefix}");
}

# Define on upper level method id
Expand All @@ -402,7 +402,7 @@ bundle agent call_method_classes_caller {
"prefix" string => canonify(nth("method_id_unique.stack", 0));

methods:
"${report_data.method_id}" usebundle => _classes_copy("${report_data.method_id}", "${prefix}");
"${report_data.method_id}" usebundle => _classes_copy("${report_data.report_id}", "${prefix}");
}

bundle agent call_method_end(method) {
Expand All @@ -421,7 +421,7 @@ bundle agent call_method_end(method) {
pass3::
"${report_data.method_id}_${method}" usebundle => enable_reporting,
if => "should_report";

reports:
pass3.debug.should_report::
"${configuration.debug} Exiting method ${method} from ${report_data.method_id}, should_report: true";
Expand Down
38 changes: 29 additions & 9 deletions tree/20_cfe_basics/log_rudder.cf
Original file line number Diff line number Diff line change
Expand Up @@ -510,20 +510,25 @@ bundle agent _method_reporting_context(c_name, c_key)
bundle agent _method_reporting_context_v4(c_name, c_key, report_id)
{
vars:
"report_data.component_name" string => "${c_name}";
"report_data.component_key" string => "${c_key}";
# Non-canonified version, to be used in reports
"report_data.report_id_r" string => "${report_id}";
# Canonified version, to be used in policies (as class prefix)
# it needs the directive_id to enforce unicity
"report_data.report_id" string => canonify("${report_id}_${report_data.directive_id}");
"report_data.method_id" string => canonify("${report_id}_${report_data.directive_id}");
"report_data.identifier" string => "${report_data.rule_id}@@${report_data.directive_id}@@${report_data.report_id_r}";
!pass1::
"report_data.index_eval" string => eval("${report_data.index}+1");
"report_data.index" int => int("${report_data.index_eval}");
"report_data.component_name" string => "${c_name}";
"report_data.component_key" string => "${c_key}";
# Non-canonified version, to be used in reports
"report_data.report_id_r" string => "${report_id}";
# Canonified version, to be used in policies (as class prefix)
# it needs the directive_id to enforce unicity
"report_data.report_id" string => canonify("${report_id}_${report_data.directive_id}");
"report_data.method_id" string => canonify("${report_id}_${report_data.directive_id}_${report_data.index}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks really complex.
we need to clearly define what is expected in report, method, and why index is necessary like (why not use something else like an auto generated id from the webapp)
there are many moving parts, in services, packages in 20_services, but also in system techniques.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added an id to track the iteration on a method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced usage a method_id to report_id (they were the same value)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use report_id effectively in reports and method_id where we need to identify the method

"report_data.identifier" string => "${report_data.rule_id}@@${report_data.directive_id}@@${report_data.report_id_r}";

methods:
"${report_id}" usebundle => rudder_method_id_reset;
debug::
"${report_data.method_id}" usebundle => dump_reporting_context;
classes:
"pass1" expression => any;
}

bundle agent rudder_reporting_context(d_id, r_id, t_name)
Expand Down Expand Up @@ -579,12 +584,27 @@ bundle agent dump_reporting_context
report_id_r = ${report_data.report_id_r}
report_id = ${report_data.report_id}
method_id = ${report_data.method_id}
index = ${report_data.index}
}";
}

bundle agent clean_method_reporting_context
{
vars:
"report_data.index" string => "0";
"report_data.component_name" string => "";
"report_data.component_key" string => "";
"report_data.identifier" string => "";
"report_data.report_id_r" string => "";
"report_data.report_id" string => "";
"report_data.method_id" string => "";
}


bundle agent clean_reporting_context
{
vars:
"report_data.index" string => "0";
"report_data.component_name" string => "";
"report_data.component_key" string => "";
"report_data.technique_name" string => "";
Expand Down