summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAnton Tolchanov <anton@tailscale.com>2023-12-12 19:14:25 +0000
committerAnton Tolchanov <1687799+knyar@users.noreply.github.com>2023-12-13 14:30:16 +0000
commit869b34ddeb4175df2b08cdc3d6cd9a350ec81059 (patch)
treea02eca4ed2bfccd954889a93c1346e535862661f
parentaffe11c503dd4dc72a184bef7b4b88b59a84899c (diff)
downloadtailscale-869b34ddeb4175df2b08cdc3d6cd9a350ec81059.tar.xz
tailscale-869b34ddeb4175df2b08cdc3d6cd9a350ec81059.zip
prober: log HTTP response body on failure
Signed-off-by: Anton Tolchanov <anton@tailscale.com>
-rw-r--r--prober/http.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/prober/http.go b/prober/http.go
index c3172a132..5c3355e46 100644
--- a/prober/http.go
+++ b/prober/http.go
@@ -53,7 +53,12 @@ func probeHTTP(ctx context.Context, url string, want []byte) error {
}
if !bytes.Contains(bs, want) {
- return fmt.Errorf("body of %q does not contain %q", url, want)
+ // Log response body, but truncate it if it's too large; the limit
+ // has been chosen arbitrarily.
+ if maxlen := 300; len(bs) > maxlen {
+ bs = bs[:maxlen]
+ }
+ return fmt.Errorf("body of %q does not contain %q (got: %q)", url, want, string(bs))
}
return nil