Fixes minor issues in the read() retries patch
Follow-up to commit c5b97eb781
.
Two things slipped through the cracks:
* ImageDownloadError was instantiated incorrectly, resulting in a wrong
error message. This was uncovered by using assertRaisesRegext in tests.
* We allowed calling write(None). This was uncovered by avoiding sleep(4)
in tests and enabling more failed calls before timeout.
Change-Id: If5e798c5461ea3e474a153574b0db2da96f2dfa8
This commit is contained in:
parent
f97f8e2c06
commit
00ad03b709
@ -356,13 +356,14 @@ class ImageDownload(object):
|
|||||||
if chunk:
|
if chunk:
|
||||||
self._last_chunk_time = time.time()
|
self._last_chunk_time = time.time()
|
||||||
self._hash_algo.update(chunk)
|
self._hash_algo.update(chunk)
|
||||||
|
yield chunk
|
||||||
elif (time.time() - self._last_chunk_time
|
elif (time.time() - self._last_chunk_time
|
||||||
> CONF.image_download_connection_timeout):
|
> CONF.image_download_connection_timeout):
|
||||||
LOG.error('Timeout reached waiting for a chunk of data from '
|
LOG.error('Timeout reached waiting for a chunk of data from '
|
||||||
'a remote server.')
|
'a remote server.')
|
||||||
raise errors.ImageDownloadError(
|
raise errors.ImageDownloadError(
|
||||||
|
self._image_info['id'],
|
||||||
'Timed out reading next chunk from webserver')
|
'Timed out reading next chunk from webserver')
|
||||||
yield chunk
|
|
||||||
|
|
||||||
def verify_image(self, image_location):
|
def verify_image(self, image_location):
|
||||||
"""Verifies the checksum of the local images matches expectations.
|
"""Verifies the checksum of the local images matches expectations.
|
||||||
|
@ -1234,8 +1234,8 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
if self.count == 1:
|
if self.count:
|
||||||
time.sleep(4)
|
time.sleep(0.1)
|
||||||
return None
|
return None
|
||||||
self.count += 1
|
self.count += 1
|
||||||
return "meow"
|
return "meow"
|
||||||
@ -1253,8 +1253,9 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
hexdigest_mock = md5_mock.return_value.hexdigest
|
hexdigest_mock = md5_mock.return_value.hexdigest
|
||||||
hexdigest_mock.return_value = image_info['checksum']
|
hexdigest_mock.return_value = image_info['checksum']
|
||||||
requests_mock.side_effect = create_timeout
|
requests_mock.side_effect = create_timeout
|
||||||
self.assertRaises(
|
self.assertRaisesRegex(
|
||||||
errors.ImageDownloadError,
|
errors.ImageDownloadError,
|
||||||
|
'Timed out reading next chunk',
|
||||||
self.agent_extension._stream_raw_image_onto_device,
|
self.agent_extension._stream_raw_image_onto_device,
|
||||||
image_info,
|
image_info,
|
||||||
'/dev/foo')
|
'/dev/foo')
|
||||||
|
Loading…
Reference in New Issue
Block a user