Catch socket.timeout for connectivity error when streaming

While fetching remote templates, if there is network issue while
reading data chunks socket.timeout is raised.

Change-Id: I4ebb495706ea3c505a92254b1f03e326b0fa34b6
Story: #2004686
Task: 28694
This commit is contained in:
Rabi Mishra 2019-01-02 13:42:08 +05:30
parent 4f9464de27
commit e3d54b74fa
1 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,8 @@
"""Utility for fetching a resource (e.g. a template) from a URL.""" """Utility for fetching a resource (e.g. a template) from a URL."""
import socket
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import requests import requests
@ -74,6 +76,6 @@ def get(url, allowed_schemes=('http', 'https')):
cfg.CONF.max_template_size) cfg.CONF.max_template_size)
return result return result
except exceptions.RequestException as ex: except (exceptions.RequestException, socket.timeout) as ex:
LOG.info('Failed to retrieve template: %s', ex) LOG.info('Failed to retrieve template: %s', ex)
raise URLFetchError(_('Failed to retrieve template from %s') % url) raise URLFetchError(_('Failed to retrieve template from %s') % url)