Skip to content

Commit 94baa84

Browse files
committed
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.
1 parent 2d5b5ce commit 94baa84

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/internal/integration/service_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,15 @@ func (s *IntegrationTestSuite) AwaitServiceReady(
255255

256256
if service.Annotations != nil {
257257
uuid := service.Annotations["k8s.cloudscale.ch/loadbalancer-uuid"]
258-
if uuid != "" {
258+
259+
// EnsureLoadBalancer sets the annotation, and then returns the
260+
// load balancer status to Kubernetes. This means there is a short
261+
// window between setting the annotation, and the service receving
262+
// its load balancer configuration.
263+
//
264+
// To avoid races, we therefore have to check for the annotation,
265+
// as well as the load balancer state.
266+
if uuid != "" && len(service.Status.LoadBalancer.Ingress) > 0 {
259267
return service
260268
}
261269
}

0 commit comments

Comments
 (0)