From 3ce1bf1b0d573881d6d26b7dd292d0510699888d Mon Sep 17 00:00:00 2001 From: Karthik S Date: Wed, 1 Dec 2021 14:55:35 +0000 Subject: [PATCH] The default max/min tx rates shall not halt deployment The default configuration of max_tx_rate and min_tx_rate is 0. Some of the SR-IOV driver implementation throws up the error for the default values and the errors shall be safely handled instead of raising an exception. Change-Id: I0e6ee35e327d36ddc1b792de1ee48bad609bc3ad (cherry picked from commit 44eab2297f4db36ede6d29a18be60da800266f01) --- os_net_config/sriov_config.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/os_net_config/sriov_config.py b/os_net_config/sriov_config.py index ebef95ca..3a7093f6 100644 --- a/os_net_config/sriov_config.py +++ b/os_net_config/sriov_config.py @@ -555,6 +555,14 @@ def get_vendor_id(ifname): return +def run_ip_config_cmd_safe(raise_error, *cmd, **kwargs): + try: + run_ip_config_cmd(*cmd) + except processutils.ProcessExecutionError: + if raise_error: + raise + + def get_pf_pci(pf_name): pf_pci_path = _get_dev_path(pf_name, "uevent") pf_info = get_file_data(pf_pci_path) @@ -602,12 +610,14 @@ def if_up_interface(device): def configure_sriov_vf(): sriov_map = _get_sriov_map() for item in sriov_map: + raise_error = True if item['device_type'] == 'vf': pf_name = item['device']['name'] vfid = item['device']['vfid'] base_cmd = ('ip', 'link', 'set', 'dev', pf_name, 'vf', str(vfid)) logger.info(f"Configuring settings for PF: {pf_name} VF: {vfid} " f"VF name: {item['name']}") + raise_error = True if 'macaddr' in item: cmd = base_cmd + ('mac', item['macaddr']) run_ip_config_cmd(*cmd) @@ -618,10 +628,14 @@ def configure_sriov_vf(): run_ip_config_cmd(*vlan_cmd) if 'max_tx_rate' in item: cmd = base_cmd + ('max_tx_rate', str(item['max_tx_rate'])) - run_ip_config_cmd(*cmd) + if item['max_tx_rate'] == 0: + raise_error = False + run_ip_config_cmd_safe(raise_error, *cmd) if 'min_tx_rate' in item: cmd = base_cmd + ('min_tx_rate', str(item['min_tx_rate'])) - run_ip_config_cmd(*cmd) + if item['min_tx_rate'] == 0: + raise_error = False + run_ip_config_cmd_safe(raise_error, *cmd) if 'spoofcheck' in item: cmd = base_cmd + ('spoofchk', item['spoofcheck']) run_ip_config_cmd(*cmd)