Merge lp:~jtran/nova/lp702580 into lp:~hudson-openstack/nova/trunk

Proposed by John Tran
Status: Merged
Approved by: Devin Carlen
Approved revision: 854
Merged at revision: 1072
Proposed branch: lp:~jtran/nova/lp702580
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 30 lines (+20/-0)
1 file modified
nova/tests/test_cloud.py (+20/-0)
To merge this branch: bzr merge lp:~jtran/nova/lp702580
Reviewer Review Type Date Requested Status
Brian Waldon (community) Needs Fixing
termie (community) Approve
Devin Carlen (community) Approve
Vish Ishaya (community) Approve
Review via email: mp+55209@code.launchpad.net

Commit message

Adds proper error handling for images that can't be found and a test for deregister image.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

Merge conflict:

37 +<<<<<<< TREE
38 +=======
39 +from nova.objectstore import image
40 +from nova.exception import NotEmpty, NotFound
41 +>>>>>>> MERGE-SOURCE

I don't think this is a good way to handle raising the exception. You lose the underlying stack trace this way and I'm not sure what value catching and raising a new exception of the same type is.

21 + try:
22 + image = self._get_image(context, image_id)
23 + except exception.NotFound:
24 + raise exception.NotFound(_('Image %s not found') %
25 + image_id)

Looks like the best way to handle would be to fix the underlying exceptions being raised.

review: Needs Fixing
Revision history for this message
John Tran (jtran) wrote :

I figured it would be good to keep consistent w/ the prior code base. See nova/api/ec2/cloud.py:describe_images.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

Yes the issue here is that we are wrapping the underlying exception with a useful error message so that it can be sent to the client. There is handling in the wsgi app for displaying NotFound, although we should perhaps call it ApiNotFound or something.

Vish

On Mar 28, 2011, at 12:08 PM, John Tran wrote:

> I figured it would be good to keep consistent w/ the prior code base. See nova/api/ec2/cloud.py:describe_images.
> --
> https://code.launchpad.net/~jtran/nova/lp702580/+merge/55209
> You are subscribed to branch lp:nova.

Revision history for this message
termie (termie) wrote :

- image no longer exists in objectstore, it was removed in the evnetlet_objectstore branch
- the branch also removed the usage of NotFound, replacing with exception.NotFound as per HACKING
- you should be using comments, not triple-quoted strings to comment your code in test_deregister_image

review: Needs Fixing
Revision history for this message
termie (termie) wrote :

- instead of from nova.exception import NotFound you should be using from nova import exception and then referencing exception.NotFound

review: Needs Fixing
Revision history for this message
John Tran (jtran) wrote :

> - instead of from nova.exception import NotFound you should be using from nova
> import exception and then referencing exception.NotFound

Thanks for the feedback. I've submitted the fix.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Brian Lamar (blamar) wrote :

Is this still valid, or did this fix the same issue:

https://code.launchpad.net/~vishvananda/nova/lp759053/+merge/57381

Revision history for this message
Vish Ishaya (vishvananda) wrote :

no this is different, fixes deregister and includes test. Looks like termie's concerns were addressed as well. Sending this off to Merge bot.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Attempt to merge into lp:nova failed due to conflicts:

text conflict in nova/tests/test_cloud.py

Revision history for this message
Jesse Andrews (anotherjesse) wrote :

John - can you merge trunk and we can try again?

Revision history for this message
termie (termie) wrote :

lgtm, btw

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Attempt to merge into lp:nova failed due to conflicts:

text conflict in nova/tests/test_cloud.py

lp:~jtran/nova/lp702580 updated
852. By John Tran

merged from trunk

Revision history for this message
Brian Waldon (bcwaldon) wrote :

12: Can you replace this exception with "ImageNotFound"? If you merge trunk, you'll see an example in describe_image_attributes.

review: Needs Fixing
lp:~jtran/nova/lp702580 updated
853. By John Tran

merged from trunk

854. By John Tran

incorporated ImageNotFound instead of NotFound

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/tests/test_cloud.py'
2--- nova/tests/test_cloud.py 2011-05-05 03:50:58 +0000
3+++ nova/tests/test_cloud.py 2011-05-12 19:52:47 +0000
4@@ -279,6 +279,26 @@
5 user_group=['all'])
6 self.assertEqual(True, result['is_public'])
7
8+ def test_deregister_image(self):
9+ deregister_image = self.cloud.deregister_image
10+
11+ def fake_delete(self, context, id):
12+ return None
13+
14+ self.stubs.Set(local.LocalImageService, 'delete', fake_delete)
15+ # valid image
16+ result = deregister_image(self.context, 'ami-00000001')
17+ self.assertEqual(result['imageId'], 'ami-00000001')
18+ # invalid image
19+ self.stubs.UnsetAll()
20+
21+ def fake_detail_empty(self, context):
22+ return []
23+
24+ self.stubs.Set(local.LocalImageService, 'detail', fake_detail_empty)
25+ self.assertRaises(exception.ImageNotFound, deregister_image,
26+ self.context, 'ami-bad001')
27+
28 def test_console_output(self):
29 instance_type = FLAGS.default_instance_type
30 max_count = 1