SRIOV: allow old sriov switch behavior that doesn't kill connection (#2294)

This commit is contained in:
mcgov 2022-10-03 14:07:22 -07:00 коммит произвёл GitHub
Родитель 11e56c922c
Коммит 27cd0345db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -21,7 +21,9 @@ class NetworkInterface(Feature):
def enabled(self) -> bool: def enabled(self) -> bool:
return True return True
def switch_sriov(self, enable: bool, wait: bool = True) -> None: def switch_sriov(
self, enable: bool, wait: bool = True, reset_connections: bool = True
) -> None:
raise NotImplementedError raise NotImplementedError
def is_enabled_sriov(self) -> bool: def is_enabled_sriov(self) -> bool:

Просмотреть файл

@ -167,7 +167,9 @@ class NetworkInterface(AwsFeatureMixin, features.NetworkInterface):
raise LisaException(f"fail to find primary nic for vm {self._node.name}") raise LisaException(f"fail to find primary nic for vm {self._node.name}")
return nic return nic
def switch_sriov(self, enable: bool, wait: bool = True) -> None: def switch_sriov(
self, enable: bool, wait: bool = True, reset_connections: bool = True
) -> None:
aws_platform: AwsPlatform = self._platform # type: ignore aws_platform: AwsPlatform = self._platform # type: ignore
instance = boto3.resource("ec2").Instance(self._instance_id) instance = boto3.resource("ec2").Instance(self._instance_id)

Просмотреть файл

@ -601,7 +601,9 @@ class NetworkInterface(AzureFeatureMixin, features.NetworkInterface):
len(all_nics) - self.origin_extra_synthetic_nics_count - 1 len(all_nics) - self.origin_extra_synthetic_nics_count - 1
) )
def switch_sriov(self, enable: bool, wait: bool = True) -> None: def switch_sriov(
self, enable: bool, wait: bool = True, reset_connections: bool = True
) -> None:
azure_platform: AzurePlatform = self._platform # type: ignore azure_platform: AzurePlatform = self._platform # type: ignore
network_client = get_network_client(azure_platform) network_client = get_network_client(azure_platform)
vm = get_vm(azure_platform, self._node) vm = get_vm(azure_platform, self._node)
@ -639,7 +641,7 @@ class NetworkInterface(AzureFeatureMixin, features.NetworkInterface):
# wait settings effective # wait settings effective
if wait: if wait:
self._check_sriov_enabled(enable) self._check_sriov_enabled(enable, reset_connections)
def is_enabled_sriov(self) -> bool: def is_enabled_sriov(self) -> bool:
azure_platform: AzurePlatform = self._platform # type: ignore azure_platform: AzurePlatform = self._platform # type: ignore
@ -774,8 +776,11 @@ class NetworkInterface(AzureFeatureMixin, features.NetworkInterface):
modprobe_tool.reload(["hv_netvsc"]) modprobe_tool.reload(["hv_netvsc"])
@retry(tries=60, delay=10) @retry(tries=60, delay=10)
def _check_sriov_enabled(self, enabled: bool) -> None: def _check_sriov_enabled(
self._node.close() self, enabled: bool, reset_connections: bool = True
) -> None:
if reset_connections:
self._node.close()
self._node.nics.reload() self._node.nics.reload()
default_nic = self._node.nics.get_nic_by_index(0) default_nic = self._node.nics.get_nic_by_index(0)

Просмотреть файл

@ -665,4 +665,5 @@ class Dpdk(TestSuite):
if modprobe.module_exists("uio_hv_generic"): if modprobe.module_exists("uio_hv_generic"):
node.tools[Service].stop_service("vpp") node.tools[Service].stop_service("vpp")
modprobe.remove(["uio_hv_generic"]) modprobe.remove(["uio_hv_generic"])
node.close()
modprobe.reload(["hv_netvsc"]) modprobe.reload(["hv_netvsc"])

Просмотреть файл

@ -333,14 +333,18 @@ def run_testpmd_concurrent(
# disable sriov (and wait for change to apply) # disable sriov (and wait for change to apply)
for node_resources in [x for x in test_kits if x.switch_sriov]: for node_resources in [x for x in test_kits if x.switch_sriov]:
node_resources.nic_controller.switch_sriov(enable=False, wait=True) node_resources.nic_controller.switch_sriov(
enable=False, wait=True, reset_connections=False
)
# let run for a bit with SRIOV disabled # let run for a bit with SRIOV disabled
time.sleep(10) time.sleep(10)
# re-enable sriov # re-enable sriov
for node_resources in [x for x in test_kits if x.switch_sriov]: for node_resources in [x for x in test_kits if x.switch_sriov]:
node_resources.nic_controller.switch_sriov(enable=True, wait=True) node_resources.nic_controller.switch_sriov(
enable=True, wait=True, reset_connections=False
)
# run for a bit with SRIOV re-enabled # run for a bit with SRIOV re-enabled
time.sleep(10) time.sleep(10)