Allow disabling keepalive_section
In case validate_connection_method already has the effect to keep alive, it should be allowed to not perform any extra keep-alive requests. Currently in MP the default keepalive section is transport-zones, which is deemed to degrade in performance a lot in scale setup. As a more light-weighted path reverse-proxy/node/health is already used, we should allow configuring keepalive section to be disabled. Change-Id: I26c0af67f90b62533a39827ca5111832d306a153
This commit is contained in:
parent
9812774970
commit
49598f4701
@ -184,6 +184,21 @@ class RequestsHTTPProviderTestCase(unittest.TestCase):
|
||||
return_value={'result_count': 1}):
|
||||
provider.validate_connection(mock_cluster, mock_ep, mock_conn)
|
||||
|
||||
def test_validate_connection_no_keep_alive(self):
|
||||
mock_conn = mocks.MockRequestSessionApi()
|
||||
mock_conn.default_headers = {}
|
||||
mock_ep = mock.Mock()
|
||||
mock_ep.provider.url = 'https://1.2.3.4'
|
||||
mock_cluster = mock.Mock()
|
||||
mock_cluster.nsxlib_config = mock.Mock()
|
||||
mock_cluster.nsxlib_config.url_base = 'abc'
|
||||
mock_cluster.nsxlib_config.keepalive_section = None
|
||||
provider = cluster.NSXRequestsHTTPProvider()
|
||||
|
||||
with mock.patch.object(client.JSONRESTClient, "get") as mock_get:
|
||||
provider.validate_connection(mock_cluster, mock_ep, mock_conn)
|
||||
mock_get.assert_not_called()
|
||||
|
||||
def _validate_con_mocks(self, nsx_version):
|
||||
nsxlib_config = nsxlib_testcase.get_default_nsxlib_config()
|
||||
nsxlib = v3.NsxLib(nsxlib_config)
|
||||
|
@ -198,14 +198,17 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
|
||||
|
||||
# If keeplive section returns a list, it is assumed to be non-empty
|
||||
keepalive_section = cluster_api.nsxlib_config.keepalive_section
|
||||
result = client.get(keepalive_section, silent=True)
|
||||
if not result or result.get('result_count', 1) <= 0:
|
||||
msg = _("No %(section)s found "
|
||||
"for '%(url)s'") % {'section': keepalive_section,
|
||||
'url': endpoint.provider.url}
|
||||
LOG.warning(msg)
|
||||
raise exceptions.ResourceNotFound(
|
||||
manager=endpoint.provider.url, operation=msg)
|
||||
# When validate connection also has the effect of keep-alive,
|
||||
# keepalive_section can be disabled by passing in an empty value
|
||||
if keepalive_section:
|
||||
result = client.get(keepalive_section, silent=True)
|
||||
if not result or result.get('result_count', 1) <= 0:
|
||||
msg = _("No %(section)s found "
|
||||
"for '%(url)s'") % {'section': keepalive_section,
|
||||
'url': endpoint.provider.url}
|
||||
LOG.warning(msg)
|
||||
raise exceptions.ResourceNotFound(
|
||||
manager=endpoint.provider.url, operation=msg)
|
||||
|
||||
def new_connection(self, cluster_api, provider):
|
||||
config = cluster_api.nsxlib_config
|
||||
|
Loading…
x
Reference in New Issue
Block a user