Merge lp:~jaypipes/glance/bug755912 into lp:~glance-coresec/glance/cactus-trunk

Proposed by Jay Pipes
Status: Merged
Approved by: Devin Carlen
Approved revision: 108
Merged at revision: 109
Proposed branch: lp:~jaypipes/glance/bug755912
Merge into: lp:~glance-coresec/glance/cactus-trunk
Diff against target: 61 lines (+35/-1)
2 files modified
glance/server.py (+1/-1)
tests/functional/test_curl_api.py (+34/-0)
To merge this branch: bzr merge lp:~jaypipes/glance/bug755912
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Rick Harris (community) Approve
justinsb Pending
Review via email: mp+57221@code.launchpad.net

Description of the change

Fix up the way the exception is raised from _safe_kill()... When I "fixed" bug 729726, I mistakenly used the traceback as the message. doh.

To post a comment you must log in.
Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm, thanks for the fix Jay!

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

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'glance/server.py'
2--- glance/server.py 2011-04-04 14:32:14 +0000
3+++ glance/server.py 2011-04-11 19:24:35 +0000
4@@ -344,7 +344,7 @@
5 # exception context was destroyed by Eventlet. To work around
6 # this, we need to 'memorize' the exception context, and then
7 # re-raise here.
8- raise exc_type(exc_traceback)
9+ raise exc_type(exc_value)
10
11 def create(self, req):
12 """
13
14=== modified file 'tests/functional/test_curl_api.py'
15--- tests/functional/test_curl_api.py 2011-04-08 02:05:38 +0000
16+++ tests/functional/test_curl_api.py 2011-04-11 19:24:35 +0000
17@@ -19,6 +19,7 @@
18
19 import json
20 import os
21+import tempfile
22 import unittest
23
24 from tests import functional
25@@ -413,3 +414,36 @@
26 self.assertTrue("X-Image-Meta-Size: %d" % FIVE_GB in out,
27 "Size was supposed to be %d. Got:\n%s."
28 % (FIVE_GB, out))
29+
30+ def test_traceback_not_consumed(self):
31+ """
32+ A test that errors coming from the POST API do not
33+ get consumed and print the actual error message, and
34+ not something like <traceback object at 0x1918d40>
35+
36+ :see https://bugs.launchpad.net/glance/+bug/755912
37+ """
38+
39+ self.cleanup()
40+ api_port, reg_port, conf_file = self.start_servers()
41+
42+ # POST /images with binary data, but not setting
43+ # Content-Type to application/octet-stream, verify a
44+ # 400 returned and that the error is readable.
45+ with tempfile.NamedTemporaryFile() as test_data_file:
46+ test_data_file.write("XXX")
47+ test_data_file.flush()
48+ cmd = ("curl -i -X POST --upload-file %s "
49+ "http://0.0.0.0:%d/images") % (test_data_file.name,
50+ api_port)
51+
52+ exitcode, out, err = execute(cmd)
53+ self.assertEqual(0, exitcode)
54+
55+ lines = out.split("\r\n")
56+ status_line = lines.pop(0)
57+
58+ self.assertEqual("HTTP/1.1 400 Bad Request", status_line)
59+ expected = "Content-Type must be application/octet-stream"
60+ self.assertTrue(expected in out,
61+ "Could not find '%s' in '%s'" % (expected, out))

Subscribers

People subscribed via source and target branches