From: Tomas Sedovic <tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=698269
When an instance got to certain states, it could not be stopped or removed
from the UI.
With this, the instance that cannot be stopped cleanly (e.g. it's in the
'error' state), will be stopped forcefully using the
`condormatic_instance_reset_error` method.
Once the instance is stopped, the corresponding deployment can be deleted (and
the instance with it).
---
src/app/controllers/instances_controller.rb | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/app/controllers/instances_controller.rb
b/src/app/controllers/instances_controller.rb
index 3914401..b3184c7 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -127,18 +127,22 @@ class InstancesController < ApplicationController
Instance.find(params[:instance_selected] || []).each do |instance|
begin
require_privilege(Privilege::USE,instance)
- unless instance.valid_action?('stop')
- raise ActionError.new("stop is an invalid action.")
- end
- # not sure if task is used as everything goes through condor
- #permissons check here
- @task = instance.queue_action(@current_user, 'stop')
- unless @task
- raise ActionError.new("stop cannot be performed on this instance.")
+ if instance.valid_action?('stop')
+ # not sure if task is used as everything goes through condor
+ #permissons check here
+ @task = instance.queue_action(@current_user, 'stop')
+ unless @task
+ raise ActionError.new("stop cannot be performed on this
instance.")
+ end
+ condormatic_instance_stop(@task)
+ notices << "#{instance.name}: stop action was successfully
queued.<br/>"
+ else
+ condormatic_instance_reset_error(instance)
+ notices << "#{instance.name}: forceful stop action was successfully
queued."
+ instance.state = Instance::STATE_STOPPED
+ instance.save!
end
- condormatic_instance_stop(@task)
- notices << "#{instance.name}: stop action was successfully
queued.<br/>"
rescue Exception => err
errors << "#{instance.name}: " + err + "<br/>"
end
--
1.7.4.4