retry apiserver errors on e2e service tests

This commit is contained in:
Antonio Ojea 2021-08-04 15:30:47 +02:00
parent 9ff3b7e744
commit 9d30eb88df

View File

@ -603,7 +603,8 @@ func (j *TestJig) waitForCondition(timeout time.Duration, message string, condit
pollFunc := func() (bool, error) { pollFunc := func() (bool, error) {
svc, err := j.Client.CoreV1().Services(j.Namespace).Get(context.TODO(), j.Name, metav1.GetOptions{}) svc, err := j.Client.CoreV1().Services(j.Namespace).Get(context.TODO(), j.Name, metav1.GetOptions{})
if err != nil { if err != nil {
return false, err framework.Logf("Retrying .... error trying to get Service %s: %v", j.Name, err)
return false, nil
} }
if conditionFn(svc) { if conditionFn(svc) {
service = svc service = svc
@ -612,7 +613,7 @@ func (j *TestJig) waitForCondition(timeout time.Duration, message string, condit
return false, nil return false, nil
} }
if err := wait.PollImmediate(framework.Poll, timeout, pollFunc); err != nil { if err := wait.PollImmediate(framework.Poll, timeout, pollFunc); err != nil {
return nil, fmt.Errorf("timed out waiting for service %q to %s", j.Name, message) return nil, fmt.Errorf("timed out waiting for service %q to %s: %w", j.Name, message, err)
} }
return service, nil return service, nil
} }