Skip to content

Commit d679e9c

Browse files
authored
Merge pull request #282 from Venkat-Kunaparaju/reduce-pods
Remove port from pod names and use pod name for service selectors
2 parents 68fd5e8 + 2626d8d commit d679e9c

9 files changed

Lines changed: 22 additions & 19 deletions

manifests/host-pod.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: {{ pod_name }}
66
labels:
77
tft-tests: {{ label_tft_tests }}
8-
tft-port: "{{ port }}"
8+
tft-pod-name: {{ pod_name }}
99
tft-network: primary
1010
spec:
1111
hostNetwork: true

manifests/pod-secondary-network.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: {{ pod_name }}
66
labels:
77
tft-tests: {{ label_tft_tests }}
8-
tft-port: "{{ port }}"
8+
tft-pod-name: {{ pod_name }}
99
tft-network: secondary
1010
annotations:
1111
k8s.v1.cni.cncf.io/networks: {{ secondary_network_nad }}

manifests/pod.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: {{ pod_name }}
66
labels:
77
tft-tests: {{ label_tft_tests }}
8-
tft-port: "{{ port }}"
8+
tft-pod-name: {{ pod_name }}
99
tft-network: primary
1010
spec:
1111
nodeSelector:

manifests/sriov-pod.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
k8s.v1.cni.cncf.io/networks: {{ secondary_network_nad }} {% endif %}
99
labels:
1010
tft-tests: {{ label_tft_tests }}
11-
tft-port: "{{ port }}"
11+
tft-pod-name: {{ pod_name }}
1212
tft-network: primary
1313
spec:
1414
nodeSelector:

manifests/svc-cluster-ip.yaml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ spec:
1515
protocol: UDP
1616
port: {{ port }}
1717
selector:
18-
tft-port: "{{ port }}"
19-
tft-network: {{ network_type }}
18+
tft-pod-name: {{ pod_name }}

manifests/svc-loadbalancer.yaml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ spec:
1616
protocol: UDP
1717
port: {{ port }}
1818
selector:
19-
tft-port: "{{ port }}"
20-
tft-network: {{ network_type }}
19+
tft-pod-name: {{ pod_name }}

manifests/svc-node-port.yaml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ spec:
1515
protocol: UDP
1616
port: {{ port }}
1717
selector:
18-
tft-port: "{{ port }}"
19-
tft-network: {{ network_type }}
18+
tft-pod-name: {{ pod_name }}

task.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ def __init__(self, ts: TestSettings):
11051105
ConnectionMode.MNP_PRIMARY_DENY,
11061106
):
11071107
in_file_template = "pod-secondary-network.yaml.j2"
1108-
pod_name = f"normal-pod-secondary-network-server-{port}"
1108+
pod_name = f"normal-pod-secondary-server-{port}"
11091109
elif pod_type == PodType.SRIOV:
11101110
in_file_template = "sriov-pod.yaml.j2"
11111111
pod_name = f"sriov-pod-server-{port}"
@@ -1145,16 +1145,20 @@ def _svc_backend_label(self) -> str:
11451145
)
11461146
return f"{prefix}-{self.port}"
11471147

1148-
def initialize(self) -> None:
1149-
super().initialize()
1150-
1148+
def ensure_services(self) -> None:
11511149
if self.in_file_template != "":
1152-
self.render_pod_file("Server Pod Yaml")
11531150
if self.get_cluster_ip() is None:
11541151
self.create_cluster_ip_service()
11551152
if self.get_nodeport_ip() is None:
11561153
self.create_node_port_service()
11571154

1155+
def initialize(self) -> None:
1156+
super().initialize()
1157+
1158+
if self.in_file_template != "":
1159+
self.render_pod_file("Server Pod Yaml")
1160+
self.ensure_services()
1161+
11581162
def _get_template_args_args(self) -> list[str]:
11591163
if not self.exec_persistent:
11601164
return []
@@ -1400,16 +1404,16 @@ def __init__(self, ts: TestSettings, server: ServerTask):
14001404
ConnectionMode.MNP_PRIMARY_DENY,
14011405
):
14021406
in_file_template = "pod-secondary-network.yaml.j2"
1403-
pod_name = f"normal-pod-secondary-network-{node_location}-client-{port}"
1407+
pod_name = f"normal-pod-secondary-{node_location}-client"
14041408
elif pod_type == PodType.SRIOV:
14051409
in_file_template = "sriov-pod.yaml.j2"
1406-
pod_name = f"sriov-pod-{node_location}-client-{port}"
1410+
pod_name = f"sriov-pod-{node_location}-client"
14071411
elif pod_type == PodType.NORMAL:
14081412
in_file_template = "pod.yaml.j2"
1409-
pod_name = f"normal-pod-{node_location}-client-{port}"
1413+
pod_name = f"normal-pod-{node_location}-client"
14101414
elif pod_type == PodType.HOSTBACKED:
14111415
in_file_template = "host-pod.yaml.j2"
1412-
pod_name = f"host-pod-{node_location}-client-{port}"
1416+
pod_name = f"host-pod-{node_location}-client"
14131417
else:
14141418
raise ValueError("Invalid pod_type {pod_type}")
14151419

trafficFlowTests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ def _provision_all_resources(self, cfg_descr: ConfigDescriptor) -> None:
419419
seen_server_pods.add(s.pod_name)
420420
s.initialize()
421421
s.start_setup(provisioning=True)
422+
else:
423+
s.ensure_services()
422424

423425
if c.pod_name not in seen_client_pods:
424426
seen_client_pods.add(c.pod_name)

0 commit comments

Comments
 (0)