Add missing comments
Change-Id: I4d59bb10b3340ae85ea8406fd238ad8843b4bc50
This commit is contained in:
parent
d411a2e0f2
commit
cc4ecafe2c
|
@ -389,13 +389,14 @@ module Deployment
|
|||
end
|
||||
end
|
||||
|
||||
# Get the list of the skipped nodes
|
||||
# @return [Array<Deployment::Node>]
|
||||
def skipped_nodes
|
||||
select do |node|
|
||||
node.skipped?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Get the list of the failed nodes
|
||||
# @return [Array<Deployment::Task>]
|
||||
def failed_tasks
|
||||
|
@ -561,6 +562,11 @@ digraph "<%= uid || 'graph' %>" {
|
|||
end.sort
|
||||
end
|
||||
|
||||
# Set the gracefully_stop condition for this cluster
|
||||
# If the provided block returns "true" the cluster will
|
||||
# stop the deployment process. This block will be validated
|
||||
# on every node visit.
|
||||
# @param [Proc] block
|
||||
def stop_condition(&block)
|
||||
self.gracefully_stop_mark = block
|
||||
end
|
||||
|
@ -586,6 +592,9 @@ digraph "<%= uid || 'graph' %>" {
|
|||
@emergency_brake
|
||||
end
|
||||
|
||||
# If the deployment is being gracefully stopped
|
||||
# set the node to the skipped state so it will
|
||||
# excluded from the deployment process.
|
||||
def gracefully_stop(node)
|
||||
if gracefully_stop? && node.ready?
|
||||
node.set_status_skipped
|
||||
|
@ -600,36 +609,44 @@ digraph "<%= uid || 'graph' %>" {
|
|||
@emergency_brake = true
|
||||
end
|
||||
|
||||
# Set the fault tolerance group setting for the cluster
|
||||
# @param [Array<Hash>] groups
|
||||
def fault_tolerance_groups=(groups=[])
|
||||
@fault_tolerance_groups = groups.select { |group| group['node_ids'].present? }
|
||||
@fault_tolerance_groups.each { |group| group['failed_node_ids'] = [] }
|
||||
debug "Setup fault tolerance groups: #{@fault_tolerance_groups}"
|
||||
end
|
||||
|
||||
# Check if this node if failed for the fault tolerance group
|
||||
# and stop the deployment if the node is failed and it sets the
|
||||
# fault tolerance count off the limit.
|
||||
# @param [Node] node
|
||||
def validate_fault_tolerance(node)
|
||||
return if gracefully_stop?
|
||||
|
||||
if node.failed?
|
||||
count_tolerance_fail(node)
|
||||
gracefully_stop! if fault_tolerance_excess?
|
||||
end
|
||||
end
|
||||
|
||||
# Set this node to be failed in the fault tolerance groups
|
||||
# @param [Node] node
|
||||
def count_tolerance_fail(node)
|
||||
fault_tolerance_groups.select do |g|
|
||||
g['node_ids'].include?(node.name)
|
||||
fault_tolerance_groups.select do |group|
|
||||
group['node_ids'].include?(node.name)
|
||||
end.each do |group|
|
||||
debug "Count failed node #{node.name} for group #{group['name']}"
|
||||
debug "Count failed node: #{node.name} for group: #{group['name']}"
|
||||
group['fault_tolerance'] -= 1
|
||||
group['node_ids'].delete(node.name)
|
||||
group['failed_node_ids'] << node.name
|
||||
end
|
||||
end
|
||||
|
||||
# Check if there are fault tolerance groups with the fault limit exceeded.
|
||||
# @return [TrueClass,FalseClass]
|
||||
def fault_tolerance_excess?
|
||||
is_failed = fault_tolerance_groups.select { |group| group['fault_tolerance'] < 0 }
|
||||
return false if is_failed.empty?
|
||||
|
||||
warn "Fault tolerance exceeded the stop conditions #{is_failed}"
|
||||
true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue