Module: Chef::Provisioning::ConvergenceStrategy::IgnoreConvergenceFailure
- Defined in:
- lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb
Overview
The purpose of this class is to decore the ‘converge` method with logic to catch any convergence failure exceptions, log them and then squelch them. The reason we need this is to prevent 1 provisioned node’s converge failing an entire provisioning recipe.
Instance Attribute Summary collapse
-
#ignore_exit_values ⇒ Object
Returns the value of attribute ignore_exit_values.
-
#ignore_failures_array ⇒ Object
Returns the value of attribute ignore_failures_array.
Class Method Summary collapse
-
.extended(instance) ⇒ Object
This module is only meant to be extended into instances, not classes or modules.
Instance Method Summary collapse
Instance Attribute Details
#ignore_exit_values ⇒ Object
Returns the value of attribute ignore_exit_values.
11 12 13 |
# File 'lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb', line 11 def ignore_exit_values @ignore_exit_values end |
#ignore_failures_array ⇒ Object
Returns the value of attribute ignore_failures_array.
11 12 13 |
# File 'lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb', line 11 def ignore_failures_array @ignore_failures_array end |
Class Method Details
.extended(instance) ⇒ Object
This module is only meant to be extended into instances, not classes or modules. Different machines may have different settings so we don’t want to extend every ‘install_sh` strategy with this logic.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb', line 16 def self.extended(instance) opts = instance.[:ignore_failure] instance.ignore_failures_array = [] instance.ignore_exit_values = [] if opts == true instance.ignore_failures_array << RuntimeError else # We assume it is integers or errors opts = [opts].flatten opts.each do |o| case when o.is_a?(Fixnum) instance.ignore_exit_values << o when o.is_a?(Range) instance.ignore_exit_values += o.to_a when o <= Exception instance.ignore_failures_array << o end end end end |
Instance Method Details
#converge(action_handler, machine) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb', line 38 def converge(action_handler, machine) super rescue SystemExit => e if ignore_exit_values.include? e.status action_handler.performed_action("Caught SystemExit error #{e.status} from converging node but ignoring it") else raise end rescue *ignore_failures_array action_handler.performed_action("Caught error '#{$!.inspect.gsub(/\n/,'\\n')}' from converging node but ignoring it") end |