From 920c0c1117f83617edc8e9f8466ca3a1f1d72efa Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Mon, 13 Mar 2017 16:43:47 -0500 Subject: [PATCH] Set OVS inactivity_probe to vsctl_timeout when adding manager If the vsctl_timeout > OVS's inactivity probe interval and a transaction execution time exceeds the probe interval, OVS will disconnect and the transaction will return TRY_AGAIN and most likely repeat failing until the vsctl_timeout is reached. This change ensures that the "failsafe" creation of the manager also sets the inactivity probe to the vsctl_timeout value. Currently the patch doesn't override the probe_interval on an existing Manager since it is possible that connection is used by outside applications and it theoretically should be handled at deployment. Related-Bug: #1627106 Change-Id: I76fa0a0cf04a166edf062086fceb2fd90960ad6b --- ovsdbapp/native/helpers.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ovsdbapp/native/helpers.py b/ovsdbapp/native/helpers.py index 12821574..08631ba3 100644 --- a/ovsdbapp/native/helpers.py +++ b/ovsdbapp/native/helpers.py @@ -12,8 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import subprocess +LOG = logging.getLogger(__name__) + def _connection_to_manager_uri(conn_uri): proto, addr = conn_uri.split(':', 1) @@ -26,10 +29,13 @@ def _connection_to_manager_uri(conn_uri): def enable_connection_uri(conn_uri, execute=None, **kwargs): timeout = kwargs.get('timeout', 5) - man_uri = 'target="%s"' % _connection_to_manager_uri(conn_uri) - cmd = ['ovs-vsctl', '--timeout=%d' % timeout, '--id=@manager', 'create', - 'Manager', man_uri, '--', 'add', 'Open_vSwitch', '.', - 'manager_options', '@manager'] + probe = timeout if kwargs.get('set_timeout') else None + man_uri = _connection_to_manager_uri(conn_uri) + cmd = ['ovs-vsctl', '--timeout=%d' % timeout, '--id=@manager', + '--', 'create', 'Manager', 'target="%s"' % man_uri, + '--', 'add', 'Open_vSwitch', '.', 'manager_options', '@manager'] + if probe: + cmd += ['--', 'set', 'Manager', man_uri, 'inactivity_probe=%s' % probe] if execute: return execute(cmd, **kwargs).rstrip() else: @@ -38,4 +44,6 @@ def enable_connection_uri(conn_uri, execute=None, **kwargs): stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = obj.communicate() + if err: + LOG.debug(err) # will fail if target already exists return out.rstrip()