@@ -78,7 +78,8 @@ func (pr httpProber) Probe(req *http.Request, timeout time.Duration) (probe.Resu
7878 Transport : pr .transport ,
7979 CheckRedirect : RedirectChecker (pr .followNonLocalRedirects ),
8080 }
81- return DoHTTPProbe (req , client )
81+ result , details , _ , err := DoHTTPProbe (req , client )
82+ return result , details , err
8283}
8384
8485// GetHTTPInterface is an interface for making HTTP requests, that returns a response and error.
@@ -90,36 +91,37 @@ type GetHTTPInterface interface {
9091// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success.
9192// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure.
9293// This is exported because some other packages may want to do direct HTTP probes.
93- func DoHTTPProbe (req * http.Request , client GetHTTPInterface ) (probe.Result , string , error ) {
94+ func DoHTTPProbe (req * http.Request , client GetHTTPInterface ) (probe.Result , string , string , error ) {
9495 url := req .URL
9596 headers := req .Header
9697 res , err := client .Do (req )
9798 if err != nil {
9899 // Convert errors into failures to catch timeouts.
99- return probe .Failure , err .Error (), nil
100+ return probe .Failure , err .Error (), "" , nil
100101 }
101102 defer res .Body .Close ()
102103 b , err := utilio .ReadAtMost (res .Body , maxRespBodyLength )
103104 if err != nil {
104105 if err == utilio .ErrLimitReached {
105106 klog .V (4 ).Infof ("Non fatal body truncation for %s, Response: %v" , url .String (), * res )
106107 } else {
107- return probe .Failure , "" , err
108+ return probe .Failure , "" , "" , err
108109 }
109110 }
110111 body := string (b )
111112 if res .StatusCode >= http .StatusOK && res .StatusCode < http .StatusBadRequest {
112113 if res .StatusCode >= http .StatusMultipleChoices { // Redirect
113114 klog .V (4 ).Infof ("Probe terminated redirects for %s, Response: %v" , url .String (), * res )
114- return probe .Warning , fmt .Sprintf ("Probe terminated redirects, Response body: %v" , body ), nil
115+ return probe .Warning , fmt .Sprintf ("Probe terminated redirects, Response body: %v" , body ), body , nil
115116 }
116117 klog .V (4 ).Infof ("Probe succeeded for %s, Response: %v" , url .String (), * res )
117- return probe .Success , body , nil
118+ return probe .Success , body , body , nil
118119 }
119120 klog .V (4 ).Infof ("Probe failed for %s with request headers %v, response body: %v" , url .String (), headers , body )
120121 // Note: Until https://issue.k8s.io/99425 is addressed, this user-facing failure message must not contain the response body.
122+ // @deads2k recommended we return the body. Slack discussion: https://redhat-internal.slack.com/archives/C04UQLWQAP3/p1679590747021409
121123 failureMsg := fmt .Sprintf ("HTTP probe failed with statuscode: %d" , res .StatusCode )
122- return probe .Failure , failureMsg , nil
124+ return probe .Failure , failureMsg , body , nil
123125}
124126
125127// RedirectChecker returns a function that can be used to check HTTP redirects.
0 commit comments