On 07/13/2011 02:58 PM, tsedovic(a)redhat.com wrote:
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
Hi,
I think condormatic_instance_reset_error doesn't work as you expect -
this call just removes a condor job, but doesn't stop an instance on
provider side. So with this patch, user can select all instances (no
matter which state they are in), click 'stop', and all instances will be
set as 'stopped' in conductor even if their real state will be different.
I remember that an idea was that we allow stop action for 'error' state
- in this situation we do direct deltacloud api query to fetch real
instance state. If it's not running, removing from condor job is OK, if
it's running, we should call 'stop' request on this instance. But to
achieve this goal condor has to expose provider instance id to
conductor. CCing Chris as he is most familiar with condor related stuff.
Jan