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 #8871: missing rudder_expected_reports.csv.res when starting the agent for the first time after an update #423

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions tree/30_generic_methods/logger_rudder.cf
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ bundle agent logger_rudder(message, class_prefix)
vars:

"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";
"expected_reports_destination" string => "${sys.workdir}/state/rudder_expected_reports.${this.promiser_pid}.csv";
# We put those files into the state directory to avoid purging them during each update
# (which would break the current run's reporting).
# We add the PID to the file name to be able to handle cuncurrent agent runs with separate expected reports
"expected_reports_temp" string => "${expected_reports_destination}.tmp";
"expected_reports_file" string => "${expected_reports_destination}.res";

pass1.(!final_resfile_exists.logger_rudder_temp_resfile_reached|logger_rudder_temp_resfile_repaired)::
# 2/ If the temporary file has been updated, read it to get all values in an array, and canonify the first entry
Expand Down Expand Up @@ -94,6 +98,31 @@ bundle agent logger_rudder(message, class_prefix)

}

# This bundle will delete the current expected reports file
# It is supposed to be called at the end of the run
bundle agent _clean_current_expected_reports_file {

vars:
"files_to_remove" slist => { "${logger_rudder.expected_reports_temp}",
"${logger_rudder.expected_reports_file}" };

files:
"${files_to_remove}"
delete => tidy;

}

# This bundle will delete expected reports files older than the given age
# It allows cleaning leftovers from interrupted executions
bundle agent _clean_old_expected_reports_file(days) {

files:
"${sys.workdir}/state/rudder_expected_reports\.\d+\.csv\.(tmp|res)"
delete => tidy,
file_select => days_old("${days}");

}

# bundle backported from rudder (prefixed with _ to avoid conflicts)
# all this whould be removed when we put this file back to rudder
#
Expand Down