mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
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.
This commit is contained in:
parent
e8a12cbfdd
commit
530b703902
@ -31,6 +31,9 @@ import (
|
|||||||
"github.com/minio/minio/cmd/logger"
|
"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
|
// Target implements logger.Target and sends the json
|
||||||
// format of a log entry to the configured http endpoint.
|
// format of a log entry to the configured http endpoint.
|
||||||
// An internal buffer of logs is maintained but when the
|
// An internal buffer of logs is maintained but when the
|
||||||
@ -62,7 +65,7 @@ func (h *Target) String() string {
|
|||||||
|
|
||||||
// Validate validate the http target
|
// Validate validate the http target
|
||||||
func (h *Target) Validate() error {
|
func (h *Target) Validate() error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 2*webhookCallTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, h.endpoint, strings.NewReader(`{}`))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, h.endpoint, strings.NewReader(`{}`))
|
||||||
@ -111,7 +114,7 @@ func (h *Target) startHTTPLogger() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), webhookCallTimeout)
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost,
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost,
|
||||||
h.endpoint, bytes.NewReader(logJSON))
|
h.endpoint, bytes.NewReader(logJSON))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user