mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Attempt to delfake further conntract e2e flakes
This commit is contained in:
parent
0c571629ab
commit
8816b8fce4
@ -3569,40 +3569,42 @@ func translatePodNameToUID(c clientset.Interface, ns string, expectedEndpoints p
|
|||||||
// validateEndpointsPorts validates that the given service exists and is served by the given expectedEndpoints.
|
// validateEndpointsPorts validates that the given service exists and is served by the given expectedEndpoints.
|
||||||
func validateEndpointsPorts(c clientset.Interface, namespace, serviceName string, expectedEndpoints portsByPodName) error {
|
func validateEndpointsPorts(c clientset.Interface, namespace, serviceName string, expectedEndpoints portsByPodName) error {
|
||||||
ginkgo.By(fmt.Sprintf("waiting up to %v for service %s in namespace %s to expose endpoints %v", framework.ServiceStartTimeout, serviceName, namespace, expectedEndpoints))
|
ginkgo.By(fmt.Sprintf("waiting up to %v for service %s in namespace %s to expose endpoints %v", framework.ServiceStartTimeout, serviceName, namespace, expectedEndpoints))
|
||||||
i := 1
|
expectedPortsByPodUID, err := translatePodNameToUID(c, namespace, expectedEndpoints)
|
||||||
for start := time.Now(); time.Since(start) < framework.ServiceStartTimeout; time.Sleep(1 * time.Second) {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := 0
|
||||||
|
if pollErr := wait.PollImmediate(time.Second, framework.ServiceStartTimeout, func() (bool, error) {
|
||||||
ep, err := c.CoreV1().Endpoints(namespace).Get(context.TODO(), serviceName, metav1.GetOptions{})
|
ep, err := c.CoreV1().Endpoints(namespace).Get(context.TODO(), serviceName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Get endpoints failed (%v elapsed, ignoring for 5s): %v", time.Since(start), err)
|
framework.Logf("Failed go get Endpoints object: %v", err)
|
||||||
continue
|
// Retry the error
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
portsByPodUID := e2eendpoints.GetContainerPortsByPodUID(ep)
|
portsByPodUID := e2eendpoints.GetContainerPortsByPodUID(ep)
|
||||||
expectedPortsByPodUID, err := translatePodNameToUID(c, namespace, expectedEndpoints)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if len(portsByPodUID) == len(expectedEndpoints) {
|
|
||||||
err := validatePorts(portsByPodUID, expectedPortsByPodUID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
framework.Logf("successfully validated that service %s in namespace %s exposes endpoints %v (%v elapsed)",
|
|
||||||
serviceName, namespace, expectedEndpoints, time.Since(start))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if i%5 == 0 {
|
|
||||||
framework.Logf("Unexpected endpoints: found %v, expected %v (%v elapsed, will retry)", portsByPodUID, expectedEndpoints, time.Since(start))
|
|
||||||
}
|
|
||||||
i++
|
i++
|
||||||
}
|
if err := validatePorts(portsByPodUID, expectedPortsByPodUID); err != nil {
|
||||||
if pods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{}); err == nil {
|
if i%5 == 0 {
|
||||||
for _, pod := range pods.Items {
|
framework.Logf("Unexpected endpoints: found %v, expected %v, will retry", portsByPodUID, expectedEndpoints)
|
||||||
framework.Logf("Pod %s\t%s\t%s\t%s", pod.Namespace, pod.Name, pod.Spec.NodeName, pod.DeletionTimestamp)
|
}
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
} else {
|
framework.Logf("successfully validated that service %s in namespace %s exposes endpoints %v",
|
||||||
framework.Logf("Can't list pod debug info: %v", err)
|
serviceName, namespace, expectedEndpoints)
|
||||||
|
return true, nil
|
||||||
|
}); pollErr != nil {
|
||||||
|
if pods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{}); err == nil {
|
||||||
|
for _, pod := range pods.Items {
|
||||||
|
framework.Logf("Pod %s\t%s\t%s\t%s", pod.Namespace, pod.Name, pod.Spec.NodeName, pod.DeletionTimestamp)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
framework.Logf("Can't list pod debug info: %v", err)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("error waithing for service %s in namespace %s to expose endpoints %v: %v", serviceName, namespace, expectedEndpoints, pollErr)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Timed out waiting for service %s in namespace %s to expose endpoints %v (%v elapsed)", serviceName, namespace, expectedEndpoints, framework.ServiceStartTimeout)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// restartApiserver restarts the kube-apiserver.
|
// restartApiserver restarts the kube-apiserver.
|
||||||
|
Loading…
Reference in New Issue
Block a user