Sha256: 39e6a6e130727527b88ffd942e142a37ae533a44e18511f08f288b69eb9783d3
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
class Chef module Provisioning class ConvergenceStrategy # 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. module IgnoreConvergenceFailure attr_accessor :ignore_failures_array, :ignore_exit_values # 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. def self.extended(instance) opts = instance.convergence_options[: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 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 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chef-provisioning-2.0.1 | lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb |