Skip to content

Commit

Permalink
Fixes #11867: Abort bundle does not work in dry-run mode
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Dec 13, 2017
1 parent 205f300 commit 89f8504
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tree/20_cfe_basics/dry_run_lib.unsupported.cf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bundle agent set_dry_run_mode(mode)
methods:
!unset_mode::
"abort" usebundle => _abort("unsupported_dryrun", "Dry-run mode is not compatible with this agent. Stopping immediately to prevent any unwanted change."),
action => immediate;
action => immediate_ignore_dry_run;

reports:
debug.unset_mode::
Expand Down
7 changes: 7 additions & 0 deletions tree/20_cfe_basics/ncf_lib.cf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ body action do_if_immediate {
action_policy => "warn";
}

# Useful for immediate call to bundles with dry-run mode on,
# as we do not want dry-run mode applied on it.
body action immediate_ignore_dry_run
{
ifelapsed => "0";
}

bundle edit_line ncf_insert_block(block) {
insert_lines:
"${block}"
Expand Down
2 changes: 1 addition & 1 deletion tree/30_generic_methods/_abort.cf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ bundle agent _abort(reason, message)
# Calling the appropriate bundle(s)
"wrapper for ${configuration.enabled_abort_handlers}"
usebundle => ${configuration.enabled_abort_handlers}("${reason}", "${message}"),
action => immediate,
action => immediate_ignore_dry_run,
comment => "Call the ${method} bundle with arguments ${reason}, ${message}";
}
2 changes: 1 addition & 1 deletion tree/30_generic_methods/_abort_default.cf
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ bundle agent _abort_default(reason, message)
{
reports:
"${configuration.fatal} Aborting agent run because of ${reason}: ${message}"
action => immediate;
action => immediate_ignore_dry_run;
}
4 changes: 2 additions & 2 deletions tree/30_generic_methods/log_rudder.cf
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ bundle agent _rudder_common_report(technique_name, status, identifier, component
send_reports.!start_run_message_sent::
"Send start message"
usebundle => _startExecution("${identifier}"),
action => immediate;
action => immediate_ignore_dry_run;

reports:
!changes_only|send_reports::
Expand All @@ -298,7 +298,7 @@ bundle agent _rudder_common_reports_generic(technique_name, class_prefix, identi
# This case should NEVER happen. If it ever happens, it is a bug in CFEngine or ncf that lead to changing something in dry-run mode.
# Hence, as we are facing a severe bug and we want to avoid changing more things, we define an abort class after displaying an error message .
"abort" usebundle => _abort("repaired_during_dryrun", "Repaired previous component while in dry-run mode, this is a bug. Aborting immediately."),
action => immediate,
action => immediate_ignore_dry_run,
ifvarclass => "(dry_run|global_dry_run).${class_prefix}_repaired";

!(dry_run|global_dry_run)::
Expand Down

0 comments on commit 89f8504

Please sign in to comment.