@@ -59,6 +59,9 @@ type podNetworkAnnotation struct {
5959 } `json:"device-info,omitempty"`
6060}
6161
62+ // createPrivilegedPodLevelBondDeployment cleans up any prior deployment, creates RBAC and a privileged
63+ // pod-level bond deployment.
64+ //
6265//nolint:funlen
6366func createPrivilegedPodLevelBondDeployment (
6467 apiClient * clients.Settings ,
@@ -159,6 +162,7 @@ func createPrivilegedPodLevelBondDeployment(
159162 return nil
160163}
161164
165+ // cleanUpPodLevelBondDeployment removes the pod-level bond deployment and waits until matching pods are gone.
162166func cleanUpPodLevelBondDeployment (apiClient * clients.Settings , deploymentName , nsName , podLabel string ) error {
163167 _ , err := deployment .Pull (apiClient , deploymentName , nsName )
164168 if err != nil {
@@ -186,6 +190,7 @@ func cleanUpPodLevelBondDeployment(apiClient *clients.Settings, deploymentName,
186190 return nil
187191}
188192
193+ // definePodLevelBondDeploymentContainer builds the privileged container spec used by pod-level bond test pods.
189194func definePodLevelBondDeploymentContainer () * pod.ContainerBuilder {
190195 cName := "test-pod"
191196
@@ -238,6 +243,8 @@ func definePodLevelBondDeploymentContainer() *pod.ContainerBuilder {
238243 return deploymentContainer
239244}
240245
246+ // definePodLevelBondTestPodDeployment constructs a deployment builder with Multus secondary networks and bond IPs.
247+ //
241248//nolint:funlen
242249func definePodLevelBondTestPodDeployment (
243250 apiClient * clients.Settings ,
@@ -347,6 +354,7 @@ func definePodLevelBondTestPodDeployment(
347354 return podDeployment , nil
348355}
349356
357+ // generateTCPTraffic runs testcmd TCP traffic from clientPod toward serverIPAddr on the bonded interface (net3).
350358func generateTCPTraffic (
351359 clientPod * pod.Builder ,
352360 serverIPAddr ,
@@ -404,6 +412,7 @@ func generateTCPTraffic(
404412 return output , nil
405413}
406414
415+ // findInCmdExecOutput scans cmdExecOutput line-by-line and reports whether stringToFind appears.
407416func findInCmdExecOutput (cmdExecOutput , stringToFind string ) (bool , error ) {
408417 var err error
409418
@@ -451,6 +460,7 @@ func findInCmdExecOutput(cmdExecOutput, stringToFind string) (bool, error) {
451460 return true , nil
452461}
453462
463+ // scanClientPodTrafficOutput checks whether pod command output indicates the TCP test passed.
454464func scanClientPodTrafficOutput (clientPodOutput string ) (bool , error ) {
455465 klog .V (100 ).Infof ("client pod output: %s" , clientPodOutput )
456466
@@ -470,6 +480,7 @@ func scanClientPodTrafficOutput(clientPodOutput string) (bool, error) {
470480 return true , nil
471481}
472482
483+ // getBondActiveInterface returns the Linux netdev name of the active bond slave under net3 for the pod.
473484func getBondActiveInterface (clientPod * pod.Builder ) (string , error ) {
474485 klog .V (90 ).Infof ("Getting bond active VF interface for the pod %s in namespace %s" ,
475486 clientPod .Definition .Name , clientPod .Definition .Namespace )
@@ -525,6 +536,7 @@ func getBondActiveInterface(clientPod *pod.Builder) (string, error) {
525536 return strings .TrimRight (result , "\r \n " ), nil
526537}
527538
539+ // disableBondActiveVFInterface disables the current bond active slave and waits until bond fails over to another VF.
528540func disableBondActiveVFInterface (clientPod * pod.Builder ) error {
529541 var err error
530542
@@ -578,6 +590,8 @@ func disableBondActiveVFInterface(clientPod *pod.Builder) error {
578590 return nil
579591}
580592
593+ // changeInterfaceState brings the named pod interface up or down.
594+ //
581595//nolint:funlen
582596func changeInterfaceState (clientPod * pod.Builder , interfaceName string , toDisable bool ) error {
583597 var (
@@ -737,6 +751,8 @@ func checkIPv6AddressState(output, ipv6Addr string) (bool, error) {
737751 return false , nil
738752}
739753
754+ // inspectPodLevelBondedInterfaceConfig validates bond net3 addresses inside the pod.
755+ //
740756//nolint:funlen,gocognit
741757func inspectPodLevelBondedInterfaceConfig (podObj * pod.Builder , ipv4Addr , ipv6Addr string ) (bool , error ) {
742758 klog .V (100 ).Infof ("Verify pod-level bonded interface configuration for pod %q in namespace %q" ,
@@ -854,6 +870,8 @@ func inspectPodLevelBondedInterfaceConfig(podObj *pod.Builder, ipv4Addr, ipv6Add
854870 return true , nil
855871}
856872
873+ // getPodObjectByNamePattern returns the first running pod in podNamespace whose name contains podNamePattern.
874+ //
857875//nolint:gocognit,funlen
858876func getPodObjectByNamePattern (apiClient * clients.Settings , podNamePattern , podNamespace string ) (* pod.Builder , error ) {
859877 var podObj * pod.Builder
@@ -988,6 +1006,7 @@ func getPodObjectByNamePattern(apiClient *clients.Settings, podNamePattern, podN
9881006 return podObj , nil
9891007}
9901008
1009+ // getBondActiveInterfaceSrIovNetworkName maps the active bond slave interface to its SR-IOV network name.
9911010func getBondActiveInterfaceSrIovNetworkName (podObj * pod.Builder ) (string , error ) {
9921011 podNetAnnotation := podObj .Object .Annotations ["k8s.v1.cni.cncf.io/network-status" ]
9931012
@@ -1051,6 +1070,7 @@ func expectTCPPass(srcPod *pod.Builder, dstIP, byStep, parseRole string) {
10511070 srcPod .Definition .Name , srcPod .Definition .Namespace , output ))
10521071}
10531072
1073+ // verifyPodLevelBondWorkloads checks bonded interface config on client and server pods and runs TCP tests both ways.
10541074func verifyPodLevelBondWorkloads (
10551075 clientDeploymentName ,
10561076 clientDeploymentNamespace ,
@@ -1117,11 +1137,12 @@ func verifyPodLevelBondWorkloads(
11171137
11181138 if clientIPv6 != "" {
11191139 expectTCPPass (serverPodObj , clientIPv6 ,
1120- "Send data from the client container to the IPv6 address used by the server container" ,
1140+ "Send data from the server container to the IPv6 address used by the client container" ,
11211141 "server" )
11221142 }
11231143}
11241144
1145+ // prepareSecondPodLevelBondDeployment creates the second (server) pod-level bond deployment for the given topology.
11251146func prepareSecondPodLevelBondDeployment (sameNode , samePF bool ) {
11261147 By ("Create privileged pod-level bond deployment" )
11271148
@@ -1199,6 +1220,7 @@ func prepareSecondPodLevelBondDeployment(sameNode, samePF bool) {
11991220 fmt .Sprintf ("Failed to create privileged pod-level bond deployment: %v" , err ))
12001221}
12011222
1223+ // verifyConnectivity runs verifyPodLevelBondWorkloads using the configured deployment-one and deployment-two IPs.
12021224func verifyConnectivity () {
12031225 verifyPodLevelBondWorkloads (
12041226 RDSCoreConfig .PodLevelBondDeploymentOneName ,
@@ -1264,7 +1286,7 @@ func runPodLevelBondTopologyCase(sameNode, samePF bool) {
12641286 verifyConnectivity ()
12651287}
12661288
1267- // VerifyPodLevelBondWorkloadsOnSameNodeSamePF verifies TCP traffic works on the same node and different PFs .
1289+ // VerifyPodLevelBondWorkloadsOnSameNodeSamePF verifies TCP traffic works on the same node and same PF .
12681290func VerifyPodLevelBondWorkloadsOnSameNodeSamePF () {
12691291 runPodLevelBondTopologyCase (true , true )
12701292}
@@ -1336,8 +1358,6 @@ func VerifyPodLevelBondWorkloadsAfterVFFailOver() {
13361358 targetIP = RDSCoreConfig .PodLevelBondDeploymentTwoIPv6
13371359 default :
13381360 Fail ("Neither IPv4 nor IPv6 server address is configured for the server deployment" )
1339-
1340- return
13411361 }
13421362
13431363 go func () {
0 commit comments