add probe warning event body like 'Probe terminated redirects'

This commit is contained in:
Paco Xu 2021-12-13 16:50:32 +08:00
parent 93d858c46e
commit 65529fe6e9
2 changed files with 5 additions and 1 deletions

View File

@ -129,6 +129,10 @@ func DoHTTPProbe(url *url.URL, headers http.Header, client GetHTTPInterface) (pr
if res.StatusCode >= http.StatusOK && res.StatusCode < http.StatusBadRequest {
if res.StatusCode >= http.StatusMultipleChoices { // Redirect
klog.V(4).Infof("Probe terminated redirects for %s, Response: %v", url.String(), *res)
// add some message in case body is empty when redirect is terminated
if len(body) == 0 {
return probe.Warning, "Probe terminated redirects", nil
}
return probe.Warning, body, nil
}
klog.V(4).Infof("Probe succeeded for %s, Response: %v", url.String(), *res)

View File

@ -310,7 +310,7 @@ var _ = SIGDescribe("Probing container", func() {
"reason": events.ContainerProbeWarning,
}.AsSelector().String()
framework.ExpectNoError(e2eevents.WaitTimeoutForEvent(
f.ClientSet, f.Namespace.Name, expectedEvent, "0.0.0.0", framework.PodEventTimeout))
f.ClientSet, f.Namespace.Name, expectedEvent, "Probe terminated redirects, Response body: <a href=\"http://0.0.0.0/\">Found</a>.", framework.PodEventTimeout))
})
/*