[NetApp] Fix lack of retry HTTP requests
The driver HTTP requester is not handling connection error with some retries for avoiding temporary network failure in name resolution. This patch adds a custom `HTTPAdapter` with 5 retries, according to urrlib3 documentation [1]. Also, the connection retry will be visible in the log [2]. [1] https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.retry [2] https://paste.opendev.org/show/bIcwjk91d4vy5Hnxxs4Z/ Closes-Bug: #1971542 Change-Id: Ic9ff8208f10df9dbed09717d6b218f6293d2338a
This commit is contained in:
parent
c81ff020f3
commit
d3310b0b38
@ -25,7 +25,9 @@ from lxml import etree
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
import requests
|
||||
from requests.adapters import HTTPAdapter
|
||||
from requests import auth
|
||||
from requests.packages.urllib3.util.retry import Retry
|
||||
|
||||
from manila import exception
|
||||
from manila.i18n import _
|
||||
@ -227,6 +229,11 @@ class BaseClient(object):
|
||||
auth_handler = self._create_certificate_auth_handler()
|
||||
|
||||
self._session = requests.Session()
|
||||
|
||||
max_retries = Retry(total=5, connect=5, read=2, backoff_factor=1)
|
||||
adapter = HTTPAdapter(max_retries=max_retries)
|
||||
self._session.mount('%s://' % self._protocol, adapter)
|
||||
|
||||
self._session.auth = auth_handler
|
||||
self._session.verify = self._ssl_verify
|
||||
headers = self._build_headers()
|
||||
@ -329,6 +336,8 @@ class ZapiClient(BaseClient):
|
||||
self._build_session()
|
||||
try:
|
||||
if hasattr(self, '_timeout'):
|
||||
if self._timeout is None:
|
||||
self._timeout = 10
|
||||
response = self._session.post(
|
||||
self._get_url(), data=request_d, timeout=self._timeout)
|
||||
else:
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Sometimes NetApp API call fails due to name resolution(DNS) issue. In
|
||||
such case, a client will now make 5 retries on connect and 2 on read
|
||||
calls. Also, the connection retry will be visible in the log. For more
|
||||
details, please refer to
|
||||
`launchpad bug #1971542 <https://bugs.launchpad.net/manila/+bug/1971542>`_
|
Loading…
Reference in New Issue
Block a user