From 530b7039025a616f3047c082f2f114d7a39b1a53 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Thu, 27 May 2021 17:54:10 +0100 Subject: [PATCH] audit/logger: Increase http request timeout (#12385) A configured audit logger or HTTP logger is validated during MinIO server startup. Relax the timeout to 10 seconds in that case, otherwise, both loggers won't be used. 1 second could be too low for a busy HTTP endpoint. --- cmd/logger/target/http/http.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/logger/target/http/http.go b/cmd/logger/target/http/http.go index 50e80aec5..dc7505543 100644 --- a/cmd/logger/target/http/http.go +++ b/cmd/logger/target/http/http.go @@ -31,6 +31,9 @@ import ( "github.com/minio/minio/cmd/logger" ) +// Timeout for the webhook http call +const webhookCallTimeout = 5 * time.Second + // Target implements logger.Target and sends the json // format of a log entry to the configured http endpoint. // An internal buffer of logs is maintained but when the @@ -62,7 +65,7 @@ func (h *Target) String() string { // Validate validate the http target func (h *Target) Validate() error { - ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 2*webhookCallTimeout) defer cancel() req, err := http.NewRequestWithContext(ctx, http.MethodPost, h.endpoint, strings.NewReader(`{}`)) @@ -111,7 +114,7 @@ func (h *Target) startHTTPLogger() { continue } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), webhookCallTimeout) req, err := http.NewRequestWithContext(ctx, http.MethodPost, h.endpoint, bytes.NewReader(logJSON)) if err != nil {