You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Ben Browning <bb...@redhat.com> on 2011/01/21 14:43:17 UTC

[PATCH] Fix Exception in Client When Destroying an Instance

This patch fixes an issue in the Ruby client where an exception is
thrown after destroying an instance (and other objects) because the
client tries to reload state information for the destroyed object.

The patch includes a test for instance destroy to verify its no longer
throws an exception.

Ben Browning (1):
  Don't reload object state after destroying

 client/lib/base_object.rb      |    3 ++-
 client/specs/instances_spec.rb |   12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

-- 
1.7.2.1


Re: [PATCH] Fix Exception in Client When Destroying an Instance

Posted by David Lutterkort <lu...@redhat.com>.
On Fri, 2011-01-21 at 08:43 -0500, Ben Browning wrote:
> This patch fixes an issue in the Ruby client where an exception is
> thrown after destroying an instance (and other objects) because the
> client tries to reload state information for the destroyed object.
> 
> The patch includes a test for instance destroy to verify its no longer
> throws an exception.
> 
> Ben Browning (1):
>   Don't reload object state after destroying

ACK. Thanks for the patch. Committed.

David



[PATCH] Don't reload object state after destroying

Posted by Ben Browning <bb...@redhat.com>.
---
 client/lib/base_object.rb      |    3 ++-
 client/specs/instances_spec.rb |   12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/client/lib/base_object.rb b/client/lib/base_object.rb
index 93c35cc..0c353c7 100644
--- a/client/lib/base_object.rb
+++ b/client/lib/base_object.rb
@@ -225,7 +225,8 @@ module DeltaCloud
       end
 
       def action_trigger(action)
-        # Refresh object state after action
+        # Refresh object state after action unless the object was destroyed
+        return if action.to_s == "destroy"
         @new_state_object = @client.send(self.base_name, self.id)
         @state = @new_state_object.state
         self.update_actions!
diff --git a/client/specs/instances_spec.rb b/client/specs/instances_spec.rb
index b976d86..c309c24 100644
--- a/client/specs/instances_spec.rb
+++ b/client/specs/instances_spec.rb
@@ -190,5 +190,17 @@ describe "instances" do
         instance.state.should eql( "RUNNING" )
       end
     end
+
+    it "should not throw exception when destroying an instance" do
+      DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
+        instance = client.create_instance( 'img1',
+                                           :name=>'TestDestroyInstance',
+                                           :hardware_profile => 'm1-xlarge' )
+        instance.stop!
+        lambda {
+          instance.destroy!
+        }.should_not raise_error
+      end
+    end
   end
 end
-- 
1.7.2.1