mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
fix: etcd not connectable when auth enabled (#31633)
Fix etcd config source didn't respect auth enabled Also removed pulsar recoverable error when pulsar return ConsumerBusy. It could happen that pulsar didn't find the original consumer is dead and recover takes some time. fix #31631 Signed-off-by: xiaofanluan <xiaofan.luan@zilliz.com>
This commit is contained in:
parent
d299fa502e
commit
b6fefee0cf
@ -216,8 +216,11 @@ func (c *mck) connectEctd() {
|
|||||||
if c.etcdIP != "" {
|
if c.etcdIP != "" {
|
||||||
etcdCli, err = etcd.GetRemoteEtcdClient([]string{c.etcdIP})
|
etcdCli, err = etcd.GetRemoteEtcdClient([]string{c.etcdIP})
|
||||||
} else {
|
} else {
|
||||||
etcdCli, err = etcd.GetEtcdClient(
|
etcdCli, err = etcd.CreateEtcdClient(
|
||||||
c.params.EtcdCfg.UseEmbedEtcd.GetAsBool(),
|
c.params.EtcdCfg.UseEmbedEtcd.GetAsBool(),
|
||||||
|
c.params.EtcdCfg.EtcdEnableAuth.GetAsBool(),
|
||||||
|
c.params.EtcdCfg.EtcdAuthUserName.GetValue(),
|
||||||
|
c.params.EtcdCfg.EtcdAuthPassword.GetValue(),
|
||||||
c.params.EtcdCfg.EtcdUseSSL.GetAsBool(),
|
c.params.EtcdCfg.EtcdUseSSL.GetAsBool(),
|
||||||
c.params.EtcdCfg.Endpoints.GetAsStrings(),
|
c.params.EtcdCfg.Endpoints.GetAsStrings(),
|
||||||
c.params.EtcdCfg.EtcdTLSCert.GetValue(),
|
c.params.EtcdCfg.EtcdTLSCert.GetValue(),
|
||||||
|
|||||||
@ -48,8 +48,11 @@ type EtcdSource struct {
|
|||||||
|
|
||||||
func NewEtcdSource(etcdInfo *EtcdInfo) (*EtcdSource, error) {
|
func NewEtcdSource(etcdInfo *EtcdInfo) (*EtcdSource, error) {
|
||||||
log.Debug("init etcd source", zap.Any("etcdInfo", etcdInfo))
|
log.Debug("init etcd source", zap.Any("etcdInfo", etcdInfo))
|
||||||
etcdCli, err := etcd.GetEtcdClient(
|
etcdCli, err := etcd.CreateEtcdClient(
|
||||||
etcdInfo.UseEmbed,
|
etcdInfo.UseEmbed,
|
||||||
|
etcdInfo.EnableAuth,
|
||||||
|
etcdInfo.UserName,
|
||||||
|
etcdInfo.PassWord,
|
||||||
etcdInfo.UseSSL,
|
etcdInfo.UseSSL,
|
||||||
etcdInfo.Endpoints,
|
etcdInfo.Endpoints,
|
||||||
etcdInfo.CertFile,
|
etcdInfo.CertFile,
|
||||||
|
|||||||
@ -36,6 +36,9 @@ type Source interface {
|
|||||||
// EtcdInfo has attribute for config center source initialization
|
// EtcdInfo has attribute for config center source initialization
|
||||||
type EtcdInfo struct {
|
type EtcdInfo struct {
|
||||||
UseEmbed bool
|
UseEmbed bool
|
||||||
|
EnableAuth bool
|
||||||
|
UserName string
|
||||||
|
PassWord string
|
||||||
UseSSL bool
|
UseSSL bool
|
||||||
Endpoints []string
|
Endpoints []string
|
||||||
KeyPrefix string
|
KeyPrefix string
|
||||||
|
|||||||
@ -18,7 +18,6 @@ package pulsar
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -31,7 +30,6 @@ import (
|
|||||||
"github.com/milvus-io/milvus/pkg/log"
|
"github.com/milvus-io/milvus/pkg/log"
|
||||||
"github.com/milvus-io/milvus/pkg/metrics"
|
"github.com/milvus-io/milvus/pkg/metrics"
|
||||||
"github.com/milvus-io/milvus/pkg/mq/msgstream/mqwrapper"
|
"github.com/milvus-io/milvus/pkg/mq/msgstream/mqwrapper"
|
||||||
"github.com/milvus-io/milvus/pkg/util/retry"
|
|
||||||
"github.com/milvus-io/milvus/pkg/util/timerecord"
|
"github.com/milvus-io/milvus/pkg/util/timerecord"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -122,9 +120,6 @@ func (pc *pulsarClient) Subscribe(options mqwrapper.ConsumerOptions) (mqwrapper.
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
metrics.MsgStreamOpCounter.WithLabelValues(metrics.CreateConsumerLabel, metrics.FailLabel).Inc()
|
metrics.MsgStreamOpCounter.WithLabelValues(metrics.CreateConsumerLabel, metrics.FailLabel).Inc()
|
||||||
if strings.Contains(err.Error(), "ConsumerBusy") {
|
|
||||||
return nil, retry.Unrecoverable(err)
|
|
||||||
}
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -668,7 +668,7 @@ func TestPulsarClient_SubscribeExclusiveFail(t *testing.T) {
|
|||||||
|
|
||||||
_, err := pc.Subscribe(mqwrapper.ConsumerOptions{Topic: "test_topic_name"})
|
_, err := pc.Subscribe(mqwrapper.ConsumerOptions{Topic: "test_topic_name"})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.False(t, retry.IsRecoverable(err))
|
assert.True(t, retry.IsRecoverable(err))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import (
|
|||||||
var maxTxnNum = 128
|
var maxTxnNum = 128
|
||||||
|
|
||||||
// GetEtcdClient returns etcd client
|
// GetEtcdClient returns etcd client
|
||||||
|
// should only used for test
|
||||||
func GetEtcdClient(
|
func GetEtcdClient(
|
||||||
useEmbedEtcd bool,
|
useEmbedEtcd bool,
|
||||||
useSSL bool,
|
useSSL bool,
|
||||||
|
|||||||
@ -191,6 +191,9 @@ func (bt *BaseTable) initConfigsFromRemote() {
|
|||||||
}
|
}
|
||||||
info := &config.EtcdInfo{
|
info := &config.EtcdInfo{
|
||||||
UseEmbed: etcdConfig.UseEmbedEtcd.GetAsBool(),
|
UseEmbed: etcdConfig.UseEmbedEtcd.GetAsBool(),
|
||||||
|
EnableAuth: etcdConfig.EtcdEnableAuth.GetAsBool(),
|
||||||
|
UserName: etcdConfig.EtcdAuthUserName.GetValue(),
|
||||||
|
PassWord: etcdConfig.EtcdAuthPassword.GetValue(),
|
||||||
UseSSL: etcdConfig.EtcdUseSSL.GetAsBool(),
|
UseSSL: etcdConfig.EtcdUseSSL.GetAsBool(),
|
||||||
Endpoints: etcdConfig.Endpoints.GetAsStrings(),
|
Endpoints: etcdConfig.Endpoints.GetAsStrings(),
|
||||||
CertFile: etcdConfig.EtcdTLSCert.GetValue(),
|
CertFile: etcdConfig.EtcdTLSCert.GetValue(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user