From 56490aaec09543398f16567349a9bb551bd70326 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Mon, 18 Nov 2024 09:52:46 -0500 Subject: [PATCH] Propagate PublishNotReadyAddresses flag to GN internal service Fixes https://github.com/submariner-io/submariner/issues/3216 Signed-off-by: Tom Pantelis --- .../controllers/global_ingressip_controller.go | 9 +++++---- .../global_ingressip_controller_test.go | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pkg/globalnet/controllers/global_ingressip_controller.go b/pkg/globalnet/controllers/global_ingressip_controller.go index 4cc5fd39e..e69ebdd42 100644 --- a/pkg/globalnet/controllers/global_ingressip_controller.go +++ b/pkg/globalnet/controllers/global_ingressip_controller.go @@ -288,10 +288,11 @@ func (c *globalIngressIPController) createOrUpdateInternalService(from *corev1.S Finalizers: []string{InternalServiceFinalizer}, }, Spec: corev1.ServiceSpec{ - Ports: from.Spec.Ports, - Selector: from.Spec.Selector, - ExternalIPs: []string{extIP}, - IPFamilyPolicy: ptr.To(corev1.IPFamilyPolicySingleStack), + Ports: from.Spec.Ports, + Selector: from.Spec.Selector, + ExternalIPs: []string{extIP}, + IPFamilyPolicy: ptr.To(corev1.IPFamilyPolicySingleStack), + PublishNotReadyAddresses: from.Spec.PublishNotReadyAddresses, }, } diff --git a/pkg/globalnet/controllers/global_ingressip_controller_test.go b/pkg/globalnet/controllers/global_ingressip_controller_test.go index 19ae9cbf2..969a348f5 100644 --- a/pkg/globalnet/controllers/global_ingressip_controller_test.go +++ b/pkg/globalnet/controllers/global_ingressip_controller_test.go @@ -132,8 +132,11 @@ var _ = Describe("GlobalIngressIP controller", func() { func testGlobalIngressIPCreatedClusterIPSvc(t *globalIngressIPControllerTestDriver, ingressIP *submarinerv1.GlobalIngressIP) { var service *corev1.Service - JustBeforeEach(func() { + BeforeEach(func() { service = newClusterIPService() + }) + + JustBeforeEach(func() { t.createService(service) t.createGlobalIngressIP(ingressIP) }) @@ -150,11 +153,23 @@ func testGlobalIngressIPCreatedClusterIPSvc(t *globalIngressIPControllerTestDriv Expect(intSvc.Spec.Ports).To(Equal(service.Spec.Ports)) Expect(intSvc.Spec.IPFamilyPolicy).ToNot(BeNil()) Expect(*intSvc.Spec.IPFamilyPolicy).To(Equal(corev1.IPFamilyPolicySingleStack)) + Expect(intSvc.Spec.PublishNotReadyAddresses).To(BeFalse()) finalizer := intSvc.GetFinalizers()[0] Expect(finalizer).To(Equal(controllers.InternalServiceFinalizer)) }) + Context("and the service has PublishNotReadyAddresses set to true", func() { + BeforeEach(func() { + service.Spec.PublishNotReadyAddresses = true + }) + + It("should set PublishNotReadyAddresses to true on the internal submariner service", func() { + intSvc := t.awaitService(controllers.GetInternalSvcName(serviceName)) + Expect(intSvc.Spec.PublishNotReadyAddresses).To(BeTrue()) + }) + }) + Context("with the IP pool exhausted", func() { BeforeEach(func() { _, err := t.pool.Allocate(t.pool.Size())