summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2012-08-06 19:25:12 -0500
committerChuck Short <chuck.short@canonical.com>2012-08-06 19:53:08 -0500
commitfe264ba158e8dc7f8b249bc6619d7001e7819c5d (patch)
tree76d1370136c2225ac33dcab3df9020e76ffd3d35
parent7015ad6fa93546a69600a354fa2080d9c0965b7d (diff)
Fix traceback when detaching volumes via EC2
When detaching a volume from an instance it results in the following traceback: Cinderclient connection created using URL: http://192.168.1.103:8776/v1/bc02ec05c5fa4a5bb3020b617f3574e2 2012-08-06 18:58:32 ERROR nova.api.ec2 [req-1fd2f017-8a11-481f-b901-ae61d3f55c94 demo demo] Unexpected error raised: 'instance_uuid' 2012-08-06 18:58:32 TRACE nova.api.ec2 Traceback (most recent call last): 2012-08-06 18:58:32 TRACE nova.api.ec2 File "/opt/stack/nova/nova/api/ec2/__init__.py", line 474, in __call__ 2012-08-06 18:58:32 TRACE nova.api.ec2 result = api_request.invoke(context) 2012-08-06 18:58:32 TRACE nova.api.ec2 File "/opt/stack/nova/nova/api/ec2/apirequest.py", line 81, in invoke 2012-08-06 18:58:32 TRACE nova.api.ec2 result = method(context, **args) 2012-08-06 18:58:32 TRACE nova.api.ec2 File "/opt/stack/nova/nova/api/ec2/cloud.py", line 799, in detach_volume 2012-08-06 18:58:32 TRACE nova.api.ec2 self.compute_api.detach_volume(context,volume_id=volume_id) 2012-08-06 18:58:32 TRACE nova.api.ec2 File "/opt/stack/nova/nova/compute/api.py", line 1642, in detach_volume 2012-08-06 18:58:32 TRACE nova.api.ec2 instance_uuid = volume['instance_uuid'] 2012-08-06 18:58:32 TRACE nova.api.ec2 KeyError: 'instance_uuid' By the time the volume in the cinder database the instance_uuid is already 'NULL', so get the instance_uuid from the volume before its detached. Fixes LP: #1033713 Change-Id: Id5515881b08af9d0832b4b620c03e471fdff0823 Signed-off-by: Chuck Short <chuck.short@canonical.com>
-rw-r--r--nova/api/ec2/cloud.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 5e85cd88a..22eb78b63 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -795,14 +795,14 @@ class CloudController(object):
volume = self.volume_api.get(context, volume_id)
try:
- instance = self.compute_api.detach_volume(context,
- volume_id=volume_id)
+ self.compute_api.detach_volume(context, volume_id=volume_id)
except exception.InvalidVolume:
raise exception.EC2APIError(_('Detach Volume Failed.'))
return {'attachTime': volume['attach_time'],
'device': volume['mountpoint'],
- 'instanceId': ec2utils.id_to_ec2_inst_id(instance['uuid']),
+ 'instanceId': ec2utils.id_to_ec2_inst_id(
+ volume['instance_uuid']),
'requestId': context.request_id,
'status': volume['attach_status'],
'volumeId': ec2utils.id_to_ec2_vol_id(volume_id)}