diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index 0a120770f..e687d10ef 100644 --- a/ironic_python_agent/extensions/standby.py +++ b/ironic_python_agent/extensions/standby.py @@ -356,13 +356,14 @@ class ImageDownload(object): if chunk: self._last_chunk_time = time.time() self._hash_algo.update(chunk) + yield chunk elif (time.time() - self._last_chunk_time > CONF.image_download_connection_timeout): LOG.error('Timeout reached waiting for a chunk of data from ' 'a remote server.') raise errors.ImageDownloadError( + self._image_info['id'], 'Timed out reading next chunk from webserver') - yield chunk def verify_image(self, image_location): """Verifies the checksum of the local images matches expectations. diff --git a/ironic_python_agent/tests/unit/extensions/test_standby.py b/ironic_python_agent/tests/unit/extensions/test_standby.py index 4fbb9e15d..5d27f6d73 100644 --- a/ironic_python_agent/tests/unit/extensions/test_standby.py +++ b/ironic_python_agent/tests/unit/extensions/test_standby.py @@ -1234,8 +1234,8 @@ class TestStandbyExtension(base.IronicAgentTest): return self def __next__(self): - if self.count == 1: - time.sleep(4) + if self.count: + time.sleep(0.1) return None self.count += 1 return "meow" @@ -1253,8 +1253,9 @@ class TestStandbyExtension(base.IronicAgentTest): hexdigest_mock = md5_mock.return_value.hexdigest hexdigest_mock.return_value = image_info['checksum'] requests_mock.side_effect = create_timeout - self.assertRaises( + self.assertRaisesRegex( errors.ImageDownloadError, + 'Timed out reading next chunk', self.agent_extension._stream_raw_image_onto_device, image_info, '/dev/foo')