diff --git a/e2e/internal/kubeclient/deploy.go b/e2e/internal/kubeclient/deploy.go index 8e4f84030..4264b66ac 100644 --- a/e2e/internal/kubeclient/deploy.go +++ b/e2e/internal/kubeclient/deploy.go @@ -217,7 +217,6 @@ func (c *Kubeclient) checkIfRunning(ctx context.Context, name string, namespace if err != nil { return false, err } - toBeRunningPods := len(pods) for _, pod := range pods { // check if all containers in the pod are running var containers []corev1.ContainerStatus @@ -226,21 +225,14 @@ func (c *Kubeclient) checkIfRunning(ctx context.Context, name string, namespace } else { containers = pod.Status.ContainerStatuses } - toBeRunningContainers := len(containers) for _, container := range containers { - if container.State.Running != nil { - toBeRunningContainers-- + if container.State.Running == nil { + return false, nil } } - if toBeRunningContainers == 0 { - toBeRunningPods-- - } - } - if toBeRunningPods == 0 { - return true, nil } - return false, nil + return true, nil } // WaitFor watches the given resource kind and blocks until the desired number of pods are @@ -408,65 +400,6 @@ loop: } } -// WaitForLoadBalancer waits until the given service is configured with an external IP and returns it. -func (c *Kubeclient) WaitForLoadBalancer(ctx context.Context, namespace, name string) (string, error) { - watcher, err := c.Client.CoreV1().Services(namespace).Watch(ctx, metav1.ListOptions{FieldSelector: "metadata.name=" + name}) - if err != nil { - return "", err - } - var ip string - var port int -loop: - for { - evt, ok := <-watcher.ResultChan() - if !ok { - if ctx.Err() == nil { - return "", fmt.Errorf("watcher for LoadBalancer %s/%s unexpectedly closed", namespace, name) - } - return "", fmt.Errorf("LoadBalancer %s/%s did not get a public IP before %w", namespace, name, ctx.Err()) - } - switch evt.Type { - case watch.Added: - fallthrough - case watch.Modified: - svc, ok := evt.Object.(*corev1.Service) - if !ok { - return "", fmt.Errorf("watcher received unexpected type %T", evt.Object) - } - for _, ingress := range svc.Status.LoadBalancer.Ingress { - if ingress.IP != "" { - ip = ingress.IP - // TODO(burgerdev): deal with more than one port, and protocols other than TCP - port = int(svc.Spec.Ports[0].Port) - break loop - } - } - case watch.Deleted: - return "", fmt.Errorf("service %s/%s was deleted while waiting for it", namespace, name) - default: - c.log.Warn("ignoring unexpected watch event", "type", evt.Type, "object", evt.Object) - } - } - - ticker := time.NewTicker(time.Second) - defer ticker.Stop() - - dialer := &net.Dialer{} - for { - select { - case <-ticker.C: - conn, err := dialer.DialContext(ctx, "tcp", net.JoinHostPort(ip, strconv.Itoa(port))) - if err == nil { - conn.Close() - return ip, nil - } - c.log.Info("probe failed", "namespace", namespace, "name", name, "error", err) - case <-ctx.Done(): - return "", fmt.Errorf("LoadBalancer %s/%s never responded to probing before %w", namespace, name, ctx.Err()) - } - } -} - func (c *Kubeclient) toJSON(a any) string { s, err := json.Marshal(a) if err != nil {