From d1735f602af93fe269a443d19056b9ede028cfcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 21 Sep 2012 17:41:23 +0200 Subject: [PATCH] appflow: Bug in shutdown procedure For straight strategy, the parents of roles UNDEPLOYING were elegible for shutdown. Now the roles must be DONE. The none stragety did not shutdown roles DEPLOYING, leaving VMs running --- flow/lcm/strategy.rb | 6 +++--- flow/lcm/strategy/straight.rb | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/flow/lcm/strategy.rb b/flow/lcm/strategy.rb index 1ce29ed4e4..718f90fb39 100644 --- a/flow/lcm/strategy.rb +++ b/flow/lcm/strategy.rb @@ -161,9 +161,9 @@ protected # @return [Hash] Roles def get_roles_shutdown(service) result = service.get_roles.select {|name, role| - role.state == Role::STATE['RUNNING'] || - role.state == Role::STATE['FAILED'] || - role.state == Role::STATE['UNKNOWN'] + role.state != Role::STATE['UNDEPLOYING'] && + role.state != Role::STATE['FAILED'] && + role.state != Role::STATE['DONE'] } # Ruby 1.8 compatibility diff --git a/flow/lcm/strategy/straight.rb b/flow/lcm/strategy/straight.rb index b901a16db2..337175b17f 100644 --- a/flow/lcm/strategy/straight.rb +++ b/flow/lcm/strategy/straight.rb @@ -100,23 +100,23 @@ module Straight # Get all the parents from running roles parents = [] - running_roles = roles.select {|name, role| - if (role.state == Role::STATE['RUNNING']|| - role.state == Role::STATE['FAILED'] || - role.state == Role::STATE['UNKNOWN'] ) + running_roles = {} + roles.each { |name, role| + # All roles can be shutdown, except the ones in these states + if (role.state != Role::STATE['UNDEPLOYING'] && + role.state != Role::STATE['FAILED'] && + role.state != Role::STATE['DONE'] ) + + running_roles[name]= role + end + + # Only the parents of DONE roles can be shutdown + if (role.state != Role::STATE['DONE'] ) parents += role.parents - true - else - false end } - # Ruby 1.8 compatibility - if running_roles.instance_of?(Array) - running_roles = Hash[running_roles] - end - # Select the nodes that are not parent from any node result = running_roles.select {|name, role| !parents.include?(name)