diff --git a/flow/client/bin/appflow b/flow/client/bin/appflow index cffb17b67c..c302ba08c1 100755 --- a/flow/client/bin/appflow +++ b/flow/client/bin/appflow @@ -367,8 +367,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do shutdown_desc = <<-EOT.unindent Shutdown a service. - From RUNNING or UNKNOWN shutdowna the Service - From FAILED_UNDEPLOYING continues shutting down the Service + From RUNNING or UNKNOWN shuts down the Service EOT command :shutdown, shutdown_desc, [:range, :serviceid_list] do @@ -386,15 +385,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do end # - # Deploy + # Recover # - deploy_desc = <<-EOT.unindent - Deploy a service + recover_desc = <<-EOT.unindent + Recover a failed service From FAILED_DEPLOYING continues deploying the Service + From FAILED_SCALING continues scaling the Service + From FAILED_UNDEPLOYING continues shutting down the Service EOT - command :deploy, deploy_desc, [:range, :serviceid_list] do + command :recover, recover_desc, [:range, :serviceid_list] do client = Service::Client.new( :username => options[:username], :password => options[:password], @@ -402,7 +403,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do :user_agent => USER_AGENT) Service.perform_actions(args[0]) { |service_id| - json_action = Service.build_json_action('deploy') + json_action = Service.build_json_action('recover') client.post("#{RESOURCE_PATH}/#{service_id}/action", json_action) } diff --git a/flow/controllers/appflow-server.rb b/flow/controllers/appflow-server.rb index 0b07d6d656..2bf6b414ee 100644 --- a/flow/controllers/appflow-server.rb +++ b/flow/controllers/appflow-server.rb @@ -184,8 +184,8 @@ post '/service/:id/action' do rc = case action['perform'] when 'shutdown' service.shutdown - when 'deploy' - service.deploy + when 'recover', 'deploy' + service.recover when 'chown' if opts && opts['owner_id'] args = Array.new diff --git a/flow/models/Role.rb b/flow/models/Role.rb index c7d195576c..9a71449765 100644 --- a/flow/models/Role.rb +++ b/flow/models/Role.rb @@ -85,7 +85,8 @@ module OpenNebula # Sets a new cardinality for this role # @param [Integer] the new cardinality def set_cardinality(target_cardinality) - msg = "Role #{name} scaling up from #{cardinality} to #{target_cardinality} nodes" + dir = target_cardinality > cardinality ? "up" : "down" + msg = "Role #{name} scaling #{dir} from #{cardinality} to #{target_cardinality} nodes" Log.info LOG_COMP, msg, @service.id() @service.log_info(msg) diff --git a/flow/models/Service.rb b/flow/models/Service.rb index 58449c024c..8de2047a60 100644 --- a/flow/models/Service.rb +++ b/flow/models/Service.rb @@ -191,17 +191,15 @@ module OpenNebula end end - # Deploy the service. This action is called when the Service is - # in FAILED_DEPLOYING and the user has fixed the problem and wants - # the deployment to continue + # Recover a failed service. This action is called when the Service is + # in FAILED_DEPLOYING or FAILED_SCALING and the user has fixed + # the problem and wants the action to continue # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise - def deploy + def recover if [Service::STATE['FAILED_DEPLOYING']].include?(self.state) self.set_state(Service::STATE['DEPLOYING']) - return self.update - # TODO: hijacked the deploy action to continue a failed scaling operation elsif self.state == Service::STATE['FAILED_SCALING'] @roles.each do |name, role| if role.state == Role::STATE['FAILED_SCALING'] @@ -211,11 +209,16 @@ module OpenNebula end self.set_state(Service::STATE['SCALING']) - return self.update + + elsif self.state == Service::STATE['FAILED_UNDEPLOYING'] + self.set_state(Service::STATE['UNDEPLOYING']) + else - return OpenNebula::Error.new("Action deploy: Wrong state" \ + return OpenNebula::Error.new("Action recover: Wrong state" \ " #{self.state_str()}") end + + return self.update end # Delete the service. All the VMs are also deleted from OpenNebula.