Merge "Prevent traceback in object-server on client disconnect"
This commit is contained in:
@@ -407,7 +407,10 @@ class ObjectController(BaseStorageServer):
|
|||||||
def _make_timeout_reader(self, file_like):
|
def _make_timeout_reader(self, file_like):
|
||||||
def timeout_reader():
|
def timeout_reader():
|
||||||
with ChunkReadTimeout(self.client_timeout):
|
with ChunkReadTimeout(self.client_timeout):
|
||||||
return file_like.read(self.network_chunk_size)
|
try:
|
||||||
|
return file_like.read(self.network_chunk_size)
|
||||||
|
except (IOError, ValueError):
|
||||||
|
raise ChunkReadError
|
||||||
return timeout_reader
|
return timeout_reader
|
||||||
|
|
||||||
def _read_put_commit_message(self, mime_documents_iter):
|
def _read_put_commit_message(self, mime_documents_iter):
|
||||||
|
@@ -1926,6 +1926,25 @@ class TestObjectController(unittest.TestCase):
|
|||||||
resp = req.get_response(self.object_controller)
|
resp = req.get_response(self.object_controller)
|
||||||
self.assertEqual(resp.status_int, 408)
|
self.assertEqual(resp.status_int, 408)
|
||||||
|
|
||||||
|
def test_PUT_client_closed_connection(self):
|
||||||
|
class fake_input(object):
|
||||||
|
def read(self, *a, **kw):
|
||||||
|
# On client disconnect during a chunked transfer, eventlet
|
||||||
|
# may raise a ValueError (or ChunkReadError, following
|
||||||
|
# https://github.com/eventlet/eventlet/commit/c3ce3ee -- but
|
||||||
|
# that inherits from ValueError)
|
||||||
|
raise ValueError
|
||||||
|
|
||||||
|
timestamp = normalize_timestamp(time())
|
||||||
|
req = Request.blank(
|
||||||
|
'/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
|
||||||
|
headers={'X-Timestamp': timestamp,
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
|
'Content-Length': '6'})
|
||||||
|
req.environ['wsgi.input'] = fake_input()
|
||||||
|
resp = req.get_response(self.object_controller)
|
||||||
|
self.assertEqual(resp.status_int, 499)
|
||||||
|
|
||||||
def test_PUT_system_metadata(self):
|
def test_PUT_system_metadata(self):
|
||||||
# check that sysmeta is stored in diskfile
|
# check that sysmeta is stored in diskfile
|
||||||
timestamp = normalize_timestamp(time())
|
timestamp = normalize_timestamp(time())
|
||||||
|
Reference in New Issue
Block a user