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.