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

@@ -26,6 +26,7 @@ import (
"net"
"sync"
"sync/atomic"
"time"
"github.com/minio/pkg/logger/message/audit"
@@ -148,18 +149,16 @@ type Config struct {
}
// Check if atleast one broker in cluster is active
func (k Config) pingBrokers() error {
var err error
func (k Config) pingBrokers() (err error) {
d := net.Dialer{Timeout: 60 * time.Second}
for _, broker := range k.Brokers {
_, err1 := net.Dial("tcp", broker.String())
if err1 != nil {
if err == nil {
// Set first error
err = err1
}
_, err = d.Dial("tcp", broker.String())
if err != nil {
return err
}
}
return err
return nil
}
// Stats returns the target statistics.