Skip to content

Commit 3bcb863

Browse files
authored
Merge pull request #289 from Venkat-Kunaparaju/same-2nd
Unify secondary pod handling and share pods under pre_provision
2 parents ed95694 + 578aed3 commit 3bcb863

4 files changed

Lines changed: 45 additions & 23 deletions

File tree

pluginValidateOffload.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,7 @@ def _thread_action() -> BaseOutput:
481481
logger.info("There is no VF on an external server")
482482
msg = "External Iperf Server"
483483
else:
484-
ifname = (
485-
"net1"
486-
if self._perf_instance._network_type == "secondary"
487-
else "eth0"
488-
)
484+
ifname = "net1" if self._perf_instance.uses_secondary_ip else "eth0"
489485
# Get VF representor - use DPU mode if configured
490486
if self._is_dpu_mode:
491487
logger.info("DPU mode: querying VF representor from DPU cluster")

task.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545

4646
EXTERNAL_PERF_SERVER = "external-perf-server"
4747

48-
_SECONDARY_MODES = (
49-
ConnectionMode.MULTI_HOME,
50-
ConnectionMode.MNP_2ND_DENY,
51-
ConnectionMode.MNP_2ND_ALLOW,
52-
)
53-
5448

5549
NP_ACTION_ALLOW = "Allow"
5650
NP_ACTION_DENY = "Deny"
@@ -302,6 +296,7 @@ def __init__(
302296
self.task_role = task_role
303297
self.in_file_template = ""
304298
self.pod_name = ""
299+
self.pod_type: Optional[PodType] = None
305300
self._setup_operation: Optional[TaskOperation] = None
306301
self._task_operation: Optional[TaskOperation] = None
307302
self._result: Optional[BaseOutput] = None
@@ -485,14 +480,19 @@ def _svc_backend_label(self) -> str:
485480

486481
@property
487482
def _network_type(self) -> str:
488-
if (
489-
self.ts.connection_mode in _SECONDARY_MODES
490-
or self.ts.test_case_id.is_udn_secondary
491-
or self.ts.test_case_id.is_udn_localnet
492-
):
483+
assert self.pod_type is not None
484+
if self.pod_type == PodType.SECONDARY:
493485
return "secondary"
494486
return "primary"
495487

488+
@property
489+
def uses_secondary_ip(self) -> bool:
490+
# MNP_PRIMARY_DENY is a SECONDARY pod, but its traffic still flows on the primary IP
491+
return (
492+
self._network_type == "secondary"
493+
and self.ts.connection_mode != ConnectionMode.MNP_PRIMARY_DENY
494+
)
495+
496496
def render_pod_file(self, log_info: str) -> None:
497497
self.render_file(
498498
log_info,
@@ -1115,9 +1115,10 @@ def __init__(self, ts: TestSettings):
11151115
elif connection_mode == ConnectionMode.EXTERNAL_IP:
11161116
in_file_template = ""
11171117
pod_name = EXTERNAL_PERF_SERVER
1118-
elif (
1119-
self._network_type == "secondary"
1120-
or connection_mode == ConnectionMode.MNP_PRIMARY_DENY
1118+
elif pod_type == PodType.SECONDARY or (
1119+
pod_type == PodType.NORMAL
1120+
and ts.cfg_descr.get_tft().pre_provision
1121+
and ts.cfg_descr.get_tft().uses_secondary_network_pod
11211122
):
11221123
in_file_template = "pod-secondary-network.yaml.j2"
11231124
pod_name = f"normal-pod-secondary-server-{port}"
@@ -1420,11 +1421,11 @@ def __init__(self, ts: TestSettings, server: ServerTask):
14201421
pod_type = ts.client_pod_type
14211422
node_location = self.node_location
14221423
port = server.port
1423-
connection_mode = ts.connection_mode
14241424

1425-
if (
1426-
self._network_type == "secondary"
1427-
or connection_mode == ConnectionMode.MNP_PRIMARY_DENY
1425+
if pod_type == PodType.SECONDARY or (
1426+
pod_type == PodType.NORMAL
1427+
and ts.cfg_descr.get_tft().pre_provision
1428+
and ts.cfg_descr.get_tft().uses_secondary_network_pod
14281429
):
14291430
in_file_template = "pod-secondary-network.yaml.j2"
14301431
pod_name = f"normal-pod-secondary-{node_location}-client"

testConfig.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ def logs_abspath(self) -> pathlib.Path:
657657
cwd=self.config.test_config.cwddir,
658658
)
659659

660+
@property
661+
def uses_secondary_network_pod(self) -> bool:
662+
return any(tc.info.uses_secondary_network_pod for tc in self.test_cases)
663+
660664
def get_output_file(self) -> pathlib.Path:
661665
output_base = self.config.test_config.output_base
662666

tftbase.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ class PodType(Enum):
408408
NORMAL = 1
409409
SRIOV = 2
410410
HOSTBACKED = 3
411+
SECONDARY = 4
411412

412413

413414
class TestCaseType(Enum):
@@ -512,6 +513,14 @@ class ConnectionMode(Enum):
512513
LOAD_BALANCER = 14
513514

514515

516+
_SECONDARY_MODES = (
517+
ConnectionMode.MULTI_HOME,
518+
ConnectionMode.MNP_2ND_DENY,
519+
ConnectionMode.MNP_2ND_ALLOW,
520+
ConnectionMode.MNP_PRIMARY_DENY,
521+
)
522+
523+
515524
@strict_dataclass
516525
@dataclass(frozen=True, kw_only=True)
517526
class Bitrate:
@@ -948,16 +957,28 @@ def node_location(self) -> str:
948957
return "same-node"
949958
return "diff-node"
950959

960+
@property
961+
def uses_secondary_network_pod(self) -> bool:
962+
return (
963+
self.connection_mode in _SECONDARY_MODES
964+
or self.test_case_type.is_udn_secondary
965+
or self.test_case_type.is_udn_localnet
966+
)
967+
951968
def get_server_pod_type(self, pod_type: PodType) -> PodType:
952969
if self.is_server_hostbacked:
953970
return PodType.HOSTBACKED
971+
if self.uses_secondary_network_pod:
972+
return PodType.SECONDARY
954973
if pod_type == PodType.SRIOV:
955974
return PodType.SRIOV
956975
return PodType.NORMAL
957976

958977
def get_client_pod_type(self, pod_type: PodType) -> PodType:
959978
if self.is_client_hostbacked:
960979
return PodType.HOSTBACKED
980+
if self.uses_secondary_network_pod:
981+
return PodType.SECONDARY
961982
if pod_type == PodType.SRIOV:
962983
return PodType.SRIOV
963984
return PodType.NORMAL

0 commit comments

Comments
 (0)