mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Retry 'service unavailable' failures in proxy test
This commit is contained in:
parent
1e2e38ad19
commit
8d98ad7a76
@ -18,6 +18,7 @@ package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -208,10 +209,19 @@ func nodeProxyTest(f *Framework, version, nodeDest string) {
|
||||
prefix := "/api/" + version
|
||||
node, err := pickNode(f.Client)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
serviceUnavailableErrors := 0
|
||||
for i := 0; i < proxyAttempts; i++ {
|
||||
_, status, d, err := doProxy(f, prefix+"/proxy/nodes/"+node+nodeDest)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(status).To(Equal(http.StatusOK))
|
||||
Expect(d).To(BeNumerically("<", 15*time.Second))
|
||||
if status == http.StatusServiceUnavailable {
|
||||
Logf("Failed proxying node logs due to service unavailable: %v", err)
|
||||
time.Sleep(time.Second)
|
||||
serviceUnavailableErrors++
|
||||
} else {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(status).To(Equal(http.StatusOK))
|
||||
Expect(d).To(BeNumerically("<", 15*time.Second))
|
||||
}
|
||||
}
|
||||
maxFailures := int(math.Floor(0.1 * float64(proxyAttempts)))
|
||||
Expect(serviceUnavailableErrors).To(BeNumerically("<", maxFailures))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user