From 2d5b5ce9563925115f86372f4e81c13dbc4f3b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Krienb=C3=BChl?= Date: Wed, 9 Apr 2025 10:07:29 +0200 Subject: [PATCH 1/2] Increase wait time for peeraddr deployment This is not the time we want to end up at, but with this change we can gather metrics on this particular test, that keeps taking longer than anticipated. Further, we no longer continue with the test if the peeraddr deployment was not successful. --- pkg/internal/integration/service_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/internal/integration/service_test.go b/pkg/internal/integration/service_test.go index ad505f1..38b5681 100644 --- a/pkg/internal/integration/service_test.go +++ b/pkg/internal/integration/service_test.go @@ -394,8 +394,9 @@ func (s *IntegrationTestSuite) TestServiceTrafficPolicyLocal() { assertPrefix := func(addr string, prefix *netip.Prefix) { url := fmt.Sprintf("http://%s", addr) successful := 0 + start := time.Now() - for i := 0; i < 60; i++ { + for i := 0; i < 120; i++ { time.Sleep(1 * time.Second) peer, err := testkit.HTTPRead(url) @@ -419,7 +420,8 @@ func (s *IntegrationTestSuite) TestServiceTrafficPolicyLocal() { } } - s.Assert().GreaterOrEqual(successful, 15) + s.T().Logf("Took %s too %s to get ready", url, time.Since(start)) + s.Require().GreaterOrEqual(successful, 15) } // Ensures the traffic is handled without unexpected delay From 94baa84b7f568a8b36ec43dbc8fd703dc40f596c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Krienb=C3=BChl?= Date: Thu, 10 Apr 2025 09:21:58 +0200 Subject: [PATCH 2/2] Await services more strictly in tests There was a race that would sometimes return a service, before it had received its load balancer addresses, causing some tests to fail rarely and randomly. --- pkg/internal/integration/service_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/internal/integration/service_test.go b/pkg/internal/integration/service_test.go index 38b5681..7b636f7 100644 --- a/pkg/internal/integration/service_test.go +++ b/pkg/internal/integration/service_test.go @@ -255,7 +255,15 @@ func (s *IntegrationTestSuite) AwaitServiceReady( if service.Annotations != nil { uuid := service.Annotations["k8s.cloudscale.ch/loadbalancer-uuid"] - if uuid != "" { + + // EnsureLoadBalancer sets the annotation, and then returns the + // load balancer status to Kubernetes. This means there is a short + // window between setting the annotation, and the service receving + // its load balancer configuration. + // + // To avoid races, we therefore have to check for the annotation, + // as well as the load balancer state. + if uuid != "" && len(service.Status.LoadBalancer.Ingress) > 0 { return service } }