mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
add Dial timeout for Kafka broker pings (#17044)
This commit is contained in:
parent
f66625be67
commit
8a9b9832fd
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user