From 56bec518b67e3f780cae12956d466d66cb05b7f8 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 4 Apr 2019 09:39:07 -0700 Subject: [PATCH] Add a request_timeout to neutron Neutron's pre-commit processing can take some time and even exceed 30 seconds in CI. Lets make it 45 and have an explicit timeout passed for the request handling to be setup with the python-neutronclient initialization. Change-Id: I9947656c959af2128e7dbf30ba6b38cc2af35dae Story: 2005371 Task: 30347 --- ironic/common/neutron.py | 3 ++- ironic/conf/neutron.py | 9 +++++++++ ironic/tests/unit/common/test_neutron.py | 6 ++++-- .../add-neutron-request-timeout-1f7372af81f14ddd.yaml | 8 ++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add-neutron-request-timeout-1f7372af81f14ddd.yaml diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py index f667e7bfba..b2834c90c4 100644 --- a/ironic/common/neutron.py +++ b/ironic/common/neutron.py @@ -87,7 +87,8 @@ def get_client(token=None, context=None): auth=user_auth or service_auth, endpoint_override=endpoint, retries=CONF.neutron.retries, - global_request_id=context.global_id) + global_request_id=context.global_id, + timeout=CONF.neutron.request_timeout) def unbind_neutron_port(port_id, client=None, context=None): diff --git a/ironic/conf/neutron.py b/ironic/conf/neutron.py index 567625543b..d2d7f41fb2 100644 --- a/ironic/conf/neutron.py +++ b/ironic/conf/neutron.py @@ -108,6 +108,15 @@ opts = [ '"neutron" network interface and not used for the ' '"flat" or "noop" network interfaces. If not ' 'specified, the default security group is used.')), + cfg.IntOpt('request_timeout', + default=45, + help=_('Timeout for request processing when interacting ' + 'with Neutron. This value should be increased if ' + 'neutron port action timeouts are observed as neutron ' + 'performs pre-commit validation prior returning to ' + 'the API client which can take longer than normal ' + 'client/server interactions.')), + ] diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index b4464edc19..1813659280 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -66,7 +66,8 @@ class TestNeutronClient(base.TestCase): session=mock.sentinel.session, auth=auth, retries=2, endpoint_override=url, - global_request_id='global') + global_request_id='global', + timeout=45) @mock.patch('ironic.common.context.RequestContext', autospec=True) def test_get_neutron_client_with_token(self, mock_ctxt, mock_client_init, @@ -84,7 +85,8 @@ class TestNeutronClient(base.TestCase): auth=mock.sentinel.sauth, retries=2, endpoint_override='neutron_url', - global_request_id=ctxt.global_id) + global_request_id=ctxt.global_id, + timeout=45) # testing handling of default url_timeout mock_session.assert_called_once_with('neutron', timeout=10) diff --git a/releasenotes/notes/add-neutron-request-timeout-1f7372af81f14ddd.yaml b/releasenotes/notes/add-neutron-request-timeout-1f7372af81f14ddd.yaml new file mode 100644 index 0000000000..eca1df044c --- /dev/null +++ b/releasenotes/notes/add-neutron-request-timeout-1f7372af81f14ddd.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fixes an issue that can occur in CI and in physical deployments where the + Networking Service performs a pre-flight operation which can exceed + the prior default for ``30`` seconds. The new default is ``45`` seconds, + and operators can tune the setting via the ``[neutron]request_timeout`` + setting.