Skip to content

Commit 578aed3

Browse files
committed
Unify secondary pod handling and share pods under pre_provision
New pod type value to capture deployments that require a secondary pod, mimicking logic used to deploy other pod types. Created a new function to determine if secondary or primary IP is required for a test case, and updated validate_offload to use this new logic. If in pre_provision mode and both primary and secondary tests are specified, only one pod is deployed for both sets of test cases, reducing the number of resources required. Currently only supported for NORMAL and SECONDARY pods. Signed-off-by: Venkat Kunaparaju <vkunaparaju@nvidia.com>
1 parent b3f1c09 commit 578aed3

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
@@ -368,6 +368,7 @@ class PodType(Enum):
368368
NORMAL = 1
369369
SRIOV = 2
370370
HOSTBACKED = 3
371+
SECONDARY = 4
371372

372373

373374
class TestCaseType(Enum):
@@ -472,6 +473,14 @@ class ConnectionMode(Enum):
472473
LOAD_BALANCER = 14
473474

474475

476+
_SECONDARY_MODES = (
477+
ConnectionMode.MULTI_HOME,
478+
ConnectionMode.MNP_2ND_DENY,
479+
ConnectionMode.MNP_2ND_ALLOW,
480+
ConnectionMode.MNP_PRIMARY_DENY,
481+
)
482+
483+
475484
@strict_dataclass
476485
@dataclass(frozen=True, kw_only=True)
477486
class Bitrate:
@@ -908,16 +917,28 @@ def node_location(self) -> str:
908917
return "same-node"
909918
return "diff-node"
910919

920+
@property
921+
def uses_secondary_network_pod(self) -> bool:
922+
return (
923+
self.connection_mode in _SECONDARY_MODES
924+
or self.test_case_type.is_udn_secondary
925+
or self.test_case_type.is_udn_localnet
926+
)
927+
911928
def get_server_pod_type(self, pod_type: PodType) -> PodType:
912929
if self.is_server_hostbacked:
913930
return PodType.HOSTBACKED
931+
if self.uses_secondary_network_pod:
932+
return PodType.SECONDARY
914933
if pod_type == PodType.SRIOV:
915934
return PodType.SRIOV
916935
return PodType.NORMAL
917936

918937
def get_client_pod_type(self, pod_type: PodType) -> PodType:
919938
if self.is_client_hostbacked:
920939
return PodType.HOSTBACKED
940+
if self.uses_secondary_network_pod:
941+
return PodType.SECONDARY
921942
if pod_type == PodType.SRIOV:
922943
return PodType.SRIOV
923944
return PodType.NORMAL

0 commit comments

Comments
 (0)