Merge "Error limit the right node on object PUT"

This commit is contained in:
Jenkins 2014-09-06 21:58:15 +00:00 committed by Gerrit Code Review
commit 6dd1933c4c
2 changed files with 22 additions and 3 deletions

View File

@ -386,17 +386,19 @@ class ObjectController(Controller):
try:
with Timeout(self.app.node_timeout):
if conn.resp:
return conn.resp
return (conn, conn.resp)
else:
return conn.getresponse()
return (conn, conn.getresponse())
except (Exception, Timeout):
self.app.exception_occurred(
conn.node, _('Object'),
_('Trying to get final status of PUT to %s') % req.path)
return (None, None)
pile = GreenAsyncPile(len(conns))
for conn in conns:
pile.spawn(get_conn_response, conn)
for response in pile:
for (conn, response) in pile:
if response:
statuses.append(response.status)
reasons.append(response.reason)

View File

@ -2608,6 +2608,23 @@ class TestObjectController(unittest.TestCase):
(200, 200, 200, 204, 204, 204), 503,
raise_exc=True)
def test_PUT_error_limiting(self):
with save_globals():
controller = proxy_server.ObjectController(self.app, 'account',
'container', 'object')
controller.app.sort_nodes = lambda l: l
object_ring = controller.app.get_object_ring(None)
self.assert_status_map(controller.PUT, (200, 200, 503, 200, 200),
200)
# 2, not 1, because assert_status_map() calls the method twice
self.assertEquals(object_ring.devs[0].get('errors', 0), 2)
self.assertEquals(object_ring.devs[1].get('errors', 0), 0)
self.assertEquals(object_ring.devs[2].get('errors', 0), 0)
self.assert_('last_error' in object_ring.devs[0])
self.assert_('last_error' not in object_ring.devs[1])
self.assert_('last_error' not in object_ring.devs[2])
def test_acc_or_con_missing_returns_404(self):
with save_globals():
self.app.memcache = FakeMemcacheReturnsNone()