add Dial timeout for Kafka broker pings (#17044)

This commit is contained in:
Harshavardhana
2023-04-17 15:45:01 -07:00
committed by GitHub
parent f66625be67
commit 8a9b9832fd
2 changed files with 12 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2015-2021 MinIO, Inc.
// Copyright (c) 2015-2023 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
@@ -28,6 +28,7 @@ import (
"net/url"
"os"
"path/filepath"
"time"
"github.com/minio/minio/internal/event"
"github.com/minio/minio/internal/logger"
@@ -268,9 +269,9 @@ func (target *KafkaTarget) Close() error {
// Check if atleast one broker in cluster is active
func (k KafkaArgs) pingBrokers() bool {
d := net.Dialer{Timeout: 60 * time.Second}
for _, broker := range k.Brokers {
_, dErr := net.Dial("tcp", broker.String())
if dErr == nil {
if _, err := d.Dial("tcp", broker.String()); err == nil {
return true
}
}