From e78d45f3680aa68a328edaf58f7b7129935bbc59 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Mon, 15 Oct 2018 15:36:01 -0400 Subject: [PATCH] Retry ovs-appctl command The ovs-appctl command may fail when setting an interface as a slave interface in a bond and the primary has not come up yet from a preceding ifup call. Retry the ovs-appctl and log an error if the command still fails. Change-Id: I3f04a5d6c3a6dc324a2978fdecd2a77df0bf1ba0 Closes-Bug: 1797955 (cherry picked from commit 25c70ea0766cee5ed456d4acb94be90247ed45ca) --- os_net_config/__init__.py | 16 +++++++++++++++- .../notes/retry_ovs-appctl-6734b087ab6db80b.yaml | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/retry_ovs-appctl-6734b087ab6db80b.yaml diff --git a/os_net_config/__init__.py b/os_net_config/__init__.py index c909701c..927907b6 100644 --- a/os_net_config/__init__.py +++ b/os_net_config/__init__.py @@ -334,5 +334,19 @@ class NetConfig(object): 'link', 'set', 'dev', newname, 'up') def ovs_appctl(self, action, *parameters): + """Run 'ovs-appctl' with the specified action + + Its possible the command may fail due to timing if, for example, + the command affects an interface and it the prior ifup command + has not completed. So retry the command and if a failures still + occurs save the error for later handling. + + :param action: The ovs-appctl action. + :param parameters: Parameters to pass to ovs-appctl. + """ msg = 'Running ovs-appctl %s %s' % (action, parameters) - self.execute(msg, '/bin/ovs-appctl', action, *parameters) + try: + self.execute(msg, '/bin/ovs-appctl', action, *parameters, + delay_on_retry=True, attempts=5) + except processutils.ProcessExecutionError as e: + self.errors.append(e) diff --git a/releasenotes/notes/retry_ovs-appctl-6734b087ab6db80b.yaml b/releasenotes/notes/retry_ovs-appctl-6734b087ab6db80b.yaml new file mode 100644 index 00000000..4e7efbf4 --- /dev/null +++ b/releasenotes/notes/retry_ovs-appctl-6734b087ab6db80b.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - The ovs-appctl command may fail, particularly when setting an + interface as a slave in a bond if the primary interface is not + yet up. Retry the ovs-appctl command and log a failure if the + command still fails.