mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
enhance: add the config to control the way when fail to init plugin (#32680)
issue: #32679 Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
parent
7da1ca9efb
commit
0ea08b008a
@ -94,7 +94,11 @@ func InitOnceHook() {
|
||||
initOnce.Do(func() {
|
||||
err := initHook()
|
||||
if err != nil {
|
||||
log.Warn("fail to init hook",
|
||||
logFunc := log.Warn
|
||||
if paramtable.Get().CommonCfg.PanicWhenPluginFail.GetAsBool() {
|
||||
logFunc = log.Panic
|
||||
}
|
||||
logFunc("fail to init hook",
|
||||
zap.String("so_path", paramtable.Get().ProxyCfg.SoPath.GetValue()),
|
||||
zap.Error(err))
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
package hookutil
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -39,6 +40,34 @@ func TestInitHook(t *testing.T) {
|
||||
paramtable.Get().Save(Params.ProxyCfg.SoPath.Key, "")
|
||||
}
|
||||
|
||||
func TestHookInitPanicError(t *testing.T) {
|
||||
paramtable.Init()
|
||||
p := paramtable.Get()
|
||||
p.Save(p.ProxyCfg.SoPath.Key, "/a/b/hook.so")
|
||||
defer p.Reset(p.ProxyCfg.SoPath.Key)
|
||||
err := initHook()
|
||||
assert.Error(t, err)
|
||||
assert.Panics(t, func() {
|
||||
initOnce = sync.Once{}
|
||||
InitOnceHook()
|
||||
})
|
||||
}
|
||||
|
||||
func TestHookInitLogError(t *testing.T) {
|
||||
paramtable.Init()
|
||||
p := paramtable.Get()
|
||||
p.Save(p.ProxyCfg.SoPath.Key, "/a/b/hook.so")
|
||||
defer p.Reset(p.ProxyCfg.SoPath.Key)
|
||||
p.Save(p.CommonCfg.PanicWhenPluginFail.Key, "false")
|
||||
defer p.Reset(p.CommonCfg.PanicWhenPluginFail.Key)
|
||||
err := initHook()
|
||||
assert.Error(t, err)
|
||||
assert.NotPanics(t, func() {
|
||||
initOnce = sync.Once{}
|
||||
InitOnceHook()
|
||||
})
|
||||
}
|
||||
|
||||
func TestDefaultHook(t *testing.T) {
|
||||
d := &DefaultHook{}
|
||||
assert.NoError(t, d.Init(nil))
|
||||
|
@ -244,6 +244,7 @@ type commonConfig struct {
|
||||
TraceLogMode ParamItem `refreshable:"true"`
|
||||
BloomFilterSize ParamItem `refreshable:"true"`
|
||||
MaxBloomFalsePositive ParamItem `refreshable:"true"`
|
||||
PanicWhenPluginFail ParamItem `refreshable:"false"`
|
||||
}
|
||||
|
||||
func (p *commonConfig) init(base *BaseTable) {
|
||||
@ -723,6 +724,14 @@ like the old password verification when updating the credential`,
|
||||
Export: true,
|
||||
}
|
||||
p.MaxBloomFalsePositive.Init(base.mgr)
|
||||
|
||||
p.PanicWhenPluginFail = ParamItem{
|
||||
Key: "common.panicWhenPluginFail",
|
||||
Version: "2.4.2",
|
||||
DefaultValue: "true",
|
||||
Doc: "panic or not when plugin fail to init",
|
||||
}
|
||||
p.PanicWhenPluginFail.Init(base.mgr)
|
||||
}
|
||||
|
||||
type gpuConfig struct {
|
||||
|
Loading…
Reference in New Issue
Block a user