[PATCH conductor] Quick Fix, destroy method is not called for ec2 and Mock instances, or if instance is in CREATE_FAILED state
Tomas Hrcka
thrcka at redhat.com
Tue Dec 13 13:41:13 UTC 2011
On 12/13/2011 02:05 PM, Jan Provaznik wrote:
> On 12/13/2011 10:37 AM, Tomas Hrcka wrote:
>> ---
>> src/app/models/instance.rb | 16 +++++++++-------
>> 1 files changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
>> index 279e1a7..d146cce 100644
>> --- a/src/app/models/instance.rb
>> +++ b/src/app/models/instance.rb
>> @@ -483,14 +483,16 @@ class Instance< ActiveRecord::Base
>> ]
>>
>> def destroy_on_provider
>> - begin
>> - @task = self.queue_action(self.owner, 'destroy')
>> - unless @task
>> - raise ActionError.new("destroy cannot be performed on this
>> instance.")
>> + if (provider_account.label != "ec2" or provider_account.label !=
>> "mock") and state != STATE_CREATE_FAILED
>
> "provider_account.provider.provider_type.deltacloud_driver" (or
> something like this) should be used for getting type of provider
>
>> + begin
>> + @task = self.queue_action(self.owner, 'destroy')
>> + unless @task
>> + raise ActionError.new("destroy cannot be performed on this
>> instance.")
>> + end
>> + Taskomatic.destroy_instance(@task)
>> + rescue Exception => e
>
> the exception should be logged (message + backtrace) in this case
>
>> + retry if self.tasks.last.action != 'destroy'
>
> this looks a little bit unsafe - if queue_action fails for any reason,
> you are trapped in busy waiting loop. If it's necessary to try it
> again, add some limited number of retries.
>
>> end
>> - Taskomatic.destroy_instance(@task)
>> - rescue Exception => e
>> - retry if self.tasks.last.action != 'destroy'
>> end
>> end
>>
>
> Hi Tomas, a couple notes inline. I think it would be great to add a
> rspec test for this new callback.
>
> Jan
Actually I have pushed it, because of shadows ACK. But I am keeping you
notes and fix the code and write rspec test today or tomorrow. Thanks!
t
More information about the aeolus-devel
mailing list