@@ -440,6 +440,10 @@ func verifyFakePodCreation(ctx context.Context, virtualNodeName string) {
440440 gomega .Expect (fakePod .Labels [cloudv1beta1 .LabelHostPortFakePod ]).To (gomega .Equal (cloudv1beta1 .LabelValueTrue ))
441441 gomega .Expect (fakePod .Labels [cloudv1beta1 .LabelManagedBy ]).To (gomega .Equal (cloudv1beta1 .LabelManagedByValue ))
442442
443+ // Verify hostNetwork is enabled (required for hostPort reservation)
444+ gomega .Expect (fakePod .Spec .HostNetwork ).To (gomega .BeTrue (),
445+ "Fake pod should have hostNetwork=true for proper hostPort reservation" )
446+
443447 // Verify tolerations (should tolerate all taints)
444448 gomega .Expect (fakePod .Spec .Tolerations ).To (gomega .ContainElement (corev1.Toleration {
445449 Operator : corev1 .TolerationOpExists ,
@@ -450,23 +454,24 @@ func verifyFakePodCreation(ctx context.Context, virtualNodeName string) {
450454 container := fakePod .Spec .Containers [0 ]
451455
452456 // Expected hostPorts from all 7 pods (sorted by HostIP, Protocol, HostPort)
457+ // Note: ContainerPort now equals HostPort because fake pod uses hostNetwork=true
453458 expectedPorts := []corev1.ContainerPort {
454459 // HostIP: hostIPAny, Protocol: TCP (sorted by HostPort)
455460 {ContainerPort : 5000 , HostPort : 5000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod6-init
456461 {ContainerPort : 5002 , HostPort : 5002 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod6-main
457462 {ContainerPort : 7000 , HostPort : 7000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod3
458- {ContainerPort : 80 , HostPort : 8000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod3
459- {ContainerPort : 81 , HostPort : 8001 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod4
460- {ContainerPort : 80 , HostPort : 8080 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod1
461- {ContainerPort : 81 , HostPort : 8081 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod1
463+ {ContainerPort : 8000 , HostPort : 8000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod3
464+ {ContainerPort : 8001 , HostPort : 8001 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod4
465+ {ContainerPort : 8080 , HostPort : 8080 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod1
466+ {ContainerPort : 8081 , HostPort : 8081 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPAny }, // Pod1
462467 // HostIP: hostIPAny, Protocol: UDP (sorted by HostPort)
463468 {ContainerPort : 5001 , HostPort : 5001 , Protocol : corev1 .ProtocolUDP , HostIP : hostIPAny }, // Pod6-init
464469 // HostIP: hostIPLocalhost, Protocol: TCP (sorted by HostPort)
465- {ContainerPort : 7001 , HostPort : 7000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPLocalhost }, // Pod4
470+ {ContainerPort : 7000 , HostPort : 7000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPLocalhost }, // Pod4
466471 {ContainerPort : 9000 , HostPort : 9000 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPLocalhost }, // Pod2
467- {ContainerPort : 9000 , HostPort : 9001 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPLocalhost }, // Pod4
472+ {ContainerPort : 9001 , HostPort : 9001 , Protocol : corev1 .ProtocolTCP , HostIP : hostIPLocalhost }, // Pod4
468473 // HostIP: hostIPLocalhost, Protocol: UDP (sorted by HostPort)
469- {ContainerPort : 9001 , HostPort : 9000 , Protocol : corev1 .ProtocolUDP , HostIP : hostIPLocalhost }, // Pod2
474+ {ContainerPort : 9000 , HostPort : 9000 , Protocol : corev1 .ProtocolUDP , HostIP : hostIPLocalhost }, // Pod2
470475 {ContainerPort : 9001 , HostPort : 9001 , Protocol : corev1 .ProtocolUDP , HostIP : hostIPLocalhost }, // Pod3
471476 // HostIP: "" (hostNetwork), Protocol: TCP (sorted by HostPort)
472477 {ContainerPort : 4000 , HostPort : 4000 , Protocol : corev1 .ProtocolTCP , HostIP : "" }, // Pod7-init
@@ -523,6 +528,9 @@ func verifyFakePodCreation(ctx context.Context, virtualNodeName string) {
523528 fmt .Sprintf ("Port %d: Protocol mismatch" , i ))
524529 gomega .Expect (actualPort .HostIP ).To (gomega .Equal (expectedPort .HostIP ),
525530 fmt .Sprintf ("Port %d: HostIP mismatch" , i ))
531+ // Verify ContainerPort equals HostPort (required for hostNetwork=true)
532+ gomega .Expect (actualPort .ContainerPort ).To (gomega .Equal (actualPort .HostPort ),
533+ fmt .Sprintf ("Port %d: ContainerPort should equal HostPort for hostNetwork pod" , i ))
526534 }
527535
528536 ginkgo .GinkgoWriter .Printf ("Verified fake pod creation with %d hostPorts\n " , len (container .Ports ))
0 commit comments