Skip to content

Commit

Permalink
enhance: support merge multi yaml files (#30910)
Browse files Browse the repository at this point in the history
related with: #22556

Signed-off-by: lixinguo <xinguo.li@zilliz.com>
Co-authored-by: lixinguo <xinguo.li@zilliz.com>
  • Loading branch information
smellthemoon and lixinguo authored Mar 15, 2024
1 parent 6f39e35 commit 6055a89
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions pkg/util/paramtable/base_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"sync"
"time"

"github.com/samber/lo"
"go.uber.org/zap"

config "github.com/milvus-io/milvus/pkg/config"
Expand Down Expand Up @@ -60,7 +59,9 @@ func globalConfigPrefixs() []string {
return []string{"metastore", "localStorage", "etcd", "tikv", "minio", "pulsar", "kafka", "rocksmq", "log", "grpc", "common", "quotaAndLimits"}
}

var defaultYaml = []string{"milvus.yaml"}
// support read "milvus.yaml", "default.yaml", "user.yaml" as this order.
// order: milvus.yaml < default.yaml < user.yaml, do not change the order below
var defaultYaml = []string{"milvus.yaml", "default.yaml", "user.yaml"}

// BaseTable the basics of paramtable
type BaseTable struct {
Expand Down Expand Up @@ -152,10 +153,22 @@ func (bt *BaseTable) init() {

func (bt *BaseTable) initConfigsFromLocal() {
refreshInterval := bt.config.refreshInterval
var files []string
for _, file := range bt.config.yamlFiles {
_, err := os.Stat(path.Join(bt.config.configDir, file))
// not found
if os.IsNotExist(err) {
continue
}
if err != nil {
log.Warn("failed to check file", zap.String("file", file), zap.Error(err))
panic(err)
}
files = append(files, path.Join(bt.config.configDir, file))
}

err := bt.mgr.AddSource(config.NewFileSource(&config.FileInfo{
Files: lo.Map(bt.config.yamlFiles, func(file string, _ int) string {
return path.Join(bt.config.configDir, file)
}),
Files: files,
RefreshInterval: time.Duration(refreshInterval) * time.Second,
}))
if err != nil {
Expand Down

0 comments on commit 6055a89

Please sign in to comment.