Skip to content

Commit

Permalink
Fixes #12297: Missing report for component \"Post-modification hook\"…
Browse files Browse the repository at this point in the history
… when cleaning files
  • Loading branch information
Fdall committed Mar 29, 2018
1 parent 4a8fc1a commit 2893b02
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,21 @@ bundle agent manageFilesAndFolders {
"pass2" expression => "pass1";
"pass1" expression => "any";

#For posthook execution
pass2::
"manageFilesAndFolders_${index}" expression => "manageFilesAndFolders_delete_${index}_modified|manageFilesAndFolders_perms_${index}_modified";
"manageFolders_${index}" expression => "manageFolders_creation_${index}_modified";
"manageFiles_${index}" expression => "manageFiles_creation_${index}_modified|manageFilesAndFolders_perms_${index}_modified";
"manageCP_${index}" expression => "manageCP_${index}_modified";
"manageSyms_${index}" expression => "manageSysms_${index}_modified";
"posthook_triggered_${index}" expression => "manageFilesAndFolders_${index}|manageFolders_${index}|manageFiles_${index}|manageCp_${index}|manageSyms_${index}";

files:
iteration_2::

# Directory
"${file[${index}][path]}/."
create => "true",
classes => kept_if_else("manageFolders_${index}_kept", "manageFolders_${index}_modified", "manageFolders_${index}_failed"),
classes => kept_if_else("manageFolders_creation_${index}_kept", "manageFolders_creation_${index}_modified", "manageFolders_creation_${index}_failed"),
comment => "Enforcing the existance of folder ${file[${index}][path]}",
ifvarclass => "(!manageFilesAndFolders_nocreate_${index}.!manageFilesAndFolders_createfile_${index}.manageFilesAndFolders_createdir_${index}).!manageFilesAndFolders_local_cp_${index}.!manageFilesAndFolders_createsymlink_${index}";

Expand Down Expand Up @@ -218,13 +226,13 @@ bundle agent manageFilesAndFolders {
# Reporting for creation
## Reporting for directory creation
"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_success", "${file[${index}][uuid]}", "File", "${file[${index}][path]}", "The folder ${file[${index}][path]} already exists"),
ifvarclass => "manageFolders_${index}_kept.!manageFolders_${index}_modified.manageFilesAndFolders_isdir_${index}.!manageFilesAndFolders_isfile_${index}.!manageFilesAndFolders_islink_${index}";
ifvarclass => "manageFolders_creation_${index}_kept.!manageFolders_creation_${index}_modified.manageFilesAndFolders_isdir_${index}.!manageFilesAndFolders_isfile_${index}.!manageFilesAndFolders_islink_${index}";

"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_repaired", "${file[${index}][uuid]}", "File", "${file[${index}][path]}", "The folder ${file[${index}][path]} was successfully created"),
ifvarclass => "manageFolders_${index}_modified";
ifvarclass => "manageFolders_creation_${index}_modified";

"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_error", "${file[${index}][uuid]}", "File", "${file[${index}][path]}", "The folder ${file[${index}][path]} could not be created"),
ifvarclass => "manageFolders_${index}_failed|manageFolders_${index}_kept.(manageFilesAndFolders_isfile_${index}|manageFilesAndFolders_islink_${index})";
ifvarclass => "manageFolders_creation_${index}_failed|manageFolders_creation_${index}_kept.(manageFilesAndFolders_isfile_${index}|manageFilesAndFolders_islink_${index})";

## Reporting for file creation
"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_success", "${file[${index}][uuid]}", "File", "${file[${index}][path]}", "The file ${file[${index}][path]} already exists"),
Expand Down Expand Up @@ -299,8 +307,11 @@ bundle agent manageFilesAndFolders {
ifvarclass => "manageFilesAndFolders_delete_${index}_failed";

# Reporting for post-command execution
"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_success", "${file[${index}][uuid]}", "Post-modification hook", "${file[${index}][path]}", "No post-execution hook set to run"),
ifvarclass => "!manageFilesAndFolders_post_hook_run_${index}";

"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_success", "${file[${index}][uuid]}", "Post-modification hook", "${file[${index}][path]}", "Post-execution hook did not need running"),
ifvarclass => "!manageFilesAndFolders_post_hook_run_${index}|((manageFiles_${index}_kept|manageFolders_${index}_kept|manageSyms_${index}_kept|manageFilesAndFolders_perms_${index}_kept).!(manageFiles_${index}_modified|manageFolders_${index}_modified|manageSyms_${index}_modified|manageFilesAndFolders_perms_${index}_modified))";
ifvarclass => "manageFilesAndFolders_post_hook_run_${index}.!posthook_triggered_${index}";

"any" usebundle => rudder_common_report("manageFilesAndFolders", "result_repaired", "${file[${index}][uuid]}", "Post-modification hook", "${file[${index}][path]}", "Post-execution hook successfully run"),
ifvarclass => "manageFilesAndFolders_${index}_command_run_ok";
Expand All @@ -309,9 +320,10 @@ bundle agent manageFilesAndFolders {
ifvarclass => "manageFilesAndFolders_${index}_command_run_failed";

commands:
pass2::
"${file[${index}][post_hook_command]}"
classes => if_else("manageFilesAndFolders_${index}_command_run_ok", "manageFilesAndFolders_${index}_command_run_failed"),
contain => in_shell,
ifvarclass => "manageFilesAndFolders_post_hook_run_${index}.(manageFiles_${index}_modified|manageFolders_${index}_modified|manageCp_${index}_modified|manageSyms_${index}_modified|manageFilesAndFolders_perms_${index}_modified)";
ifvarclass => "manageFilesAndFolders_post_hook_run_${index}.posthook_triggered_${index}";

}

0 comments on commit 2893b02

Please sign in to comment.