Skip to content

Commit 8816b8f

Browse files
committed
Attempt to delfake further conntract e2e flakes
1 parent 0c57162 commit 8816b8f

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

test/e2e/network/service.go

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,40 +3569,42 @@ func translatePodNameToUID(c clientset.Interface, ns string, expectedEndpoints p
35693569
// validateEndpointsPorts validates that the given service exists and is served by the given expectedEndpoints.
35703570
func validateEndpointsPorts(c clientset.Interface, namespace, serviceName string, expectedEndpoints portsByPodName) error {
35713571
ginkgo.By(fmt.Sprintf("waiting up to %v for service %s in namespace %s to expose endpoints %v", framework.ServiceStartTimeout, serviceName, namespace, expectedEndpoints))
3572-
i := 1
3573-
for start := time.Now(); time.Since(start) < framework.ServiceStartTimeout; time.Sleep(1 * time.Second) {
3572+
expectedPortsByPodUID, err := translatePodNameToUID(c, namespace, expectedEndpoints)
3573+
if err != nil {
3574+
return err
3575+
}
3576+
3577+
i := 0
3578+
if pollErr := wait.PollImmediate(time.Second, framework.ServiceStartTimeout, func() (bool, error) {
35743579
ep, err := c.CoreV1().Endpoints(namespace).Get(context.TODO(), serviceName, metav1.GetOptions{})
35753580
if err != nil {
3576-
framework.Logf("Get endpoints failed (%v elapsed, ignoring for 5s): %v", time.Since(start), err)
3577-
continue
3581+
framework.Logf("Failed go get Endpoints object: %v", err)
3582+
// Retry the error
3583+
return false, nil
35783584
}
35793585
portsByPodUID := e2eendpoints.GetContainerPortsByPodUID(ep)
3580-
expectedPortsByPodUID, err := translatePodNameToUID(c, namespace, expectedEndpoints)
3581-
if err != nil {
3582-
return err
3583-
}
3584-
if len(portsByPodUID) == len(expectedEndpoints) {
3585-
err := validatePorts(portsByPodUID, expectedPortsByPodUID)
3586-
if err != nil {
3587-
return err
3586+
3587+
i++
3588+
if err := validatePorts(portsByPodUID, expectedPortsByPodUID); err != nil {
3589+
if i%5 == 0 {
3590+
framework.Logf("Unexpected endpoints: found %v, expected %v, will retry", portsByPodUID, expectedEndpoints)
35883591
}
3589-
framework.Logf("successfully validated that service %s in namespace %s exposes endpoints %v (%v elapsed)",
3590-
serviceName, namespace, expectedEndpoints, time.Since(start))
3591-
return nil
3592-
}
3593-
if i%5 == 0 {
3594-
framework.Logf("Unexpected endpoints: found %v, expected %v (%v elapsed, will retry)", portsByPodUID, expectedEndpoints, time.Since(start))
3592+
return false, nil
35953593
}
3596-
i++
3597-
}
3598-
if pods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{}); err == nil {
3599-
for _, pod := range pods.Items {
3600-
framework.Logf("Pod %s\t%s\t%s\t%s", pod.Namespace, pod.Name, pod.Spec.NodeName, pod.DeletionTimestamp)
3594+
framework.Logf("successfully validated that service %s in namespace %s exposes endpoints %v",
3595+
serviceName, namespace, expectedEndpoints)
3596+
return true, nil
3597+
}); pollErr != nil {
3598+
if pods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{}); err == nil {
3599+
for _, pod := range pods.Items {
3600+
framework.Logf("Pod %s\t%s\t%s\t%s", pod.Namespace, pod.Name, pod.Spec.NodeName, pod.DeletionTimestamp)
3601+
}
3602+
} else {
3603+
framework.Logf("Can't list pod debug info: %v", err)
36013604
}
3602-
} else {
3603-
framework.Logf("Can't list pod debug info: %v", err)
3605+
return fmt.Errorf("error waithing for service %s in namespace %s to expose endpoints %v: %v", serviceName, namespace, expectedEndpoints, pollErr)
36043606
}
3605-
return fmt.Errorf("Timed out waiting for service %s in namespace %s to expose endpoints %v (%v elapsed)", serviceName, namespace, expectedEndpoints, framework.ServiceStartTimeout)
3607+
return nil
36063608
}
36073609

36083610
// restartApiserver restarts the kube-apiserver.

0 commit comments

Comments
 (0)