Skip to content

Commit

Permalink
fix: enable milvus.yaml check (#34567) (#35446)
Browse files Browse the repository at this point in the history
See #32168

pr: #34567 #35152

---------

Signed-off-by: Ted Xu <[email protected]>
  • Loading branch information
tedxu authored Aug 13, 2024
1 parent acd3c53 commit ce53e79
Show file tree
Hide file tree
Showing 9 changed files with 535 additions and 307 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ clean:

milvus-tools: print-build-info
@echo "Building tools ..."
@mkdir -p $(INSTALL_PATH)/tools && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build \
@. $(PWD)/scripts/setenv.sh && mkdir -p $(INSTALL_PATH)/tools && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build \
-pgo=$(PGO_PATH)/default.pgo -ldflags="-X 'main.BuildTags=$(BUILD_TAGS)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.GitCommit=$(GIT_COMMIT)' -X 'main.GoVersion=$(GO_VERSION)'" \
-o $(INSTALL_PATH)/tools $(PWD)/cmd/tools/* 1>/dev/null

Expand Down
16 changes: 9 additions & 7 deletions cmd/tools/config-docs-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ func (s Section) sectionPageContent() string {
ret += fmt.Sprintf("# %s-related Configurations"+mdNextLine, s.Name)
ret += s.descriptionContent() + mdNextLine
for _, field := range s.Fields {
if len(field.Description) == 0 || field.Description[0] == "" {
continue
}
ret += field.sectionPageContent() + mdNextLine
}

Expand Down Expand Up @@ -248,21 +251,20 @@ const fieldTableTemplate = `<table id="%s">
func (f Field) sectionPageContent() string {
ret := fmt.Sprintf("## `%s`", f.Name) + mdNextLine
desp := f.descriptionContent()
if len(desp) > 0 {
desp = "\n" + desp + " "
}
ret += fmt.Sprintf(fieldTableTemplate, f.Name, desp, f.DefaultValue)
return ret
}

func (f Field) descriptionContent() string {
var ret string
lines := len(f.Description)
for i, descLine := range f.Description {
ret += fmt.Sprintf(" <li>%s</li>", descLine)
if i < lines-1 {
ret += "\n"
if lines > 1 {
for _, descLine := range f.Description {
ret += fmt.Sprintf("\n <li>%s</li> ", descLine)
}
} else {
ret = fmt.Sprintf(" %s ", f.Description[0])
}

return ret
}
9 changes: 8 additions & 1 deletion cmd/tools/config/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"bytes"
"fmt"
"os"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -30,20 +31,26 @@ import (
// Please be noted that milvus.yaml is generated by code, so don't edit it directly, instead, change the code in paramtable
// and run `make milvus-tools && ./bin/tools/config gen-yaml && mv milvus.yaml configs/milvus.yaml`.
func TestYamlFile(t *testing.T) {
log.SetLevel(zap.InfoLevel)
w := bytes.Buffer{}
WriteYaml(&w)

base := paramtable.NewBaseTable()
f, err := os.Open(fmt.Sprintf("%s/%s", base.GetConfigDir(), "milvus.yaml"))
assert.NoError(t, err, "expecting configs/milvus.yaml")
log.Info("Verifying config", zap.String("file", f.Name()))
defer f.Close()
fileScanner := bufio.NewScanner(f)
codeScanner := bufio.NewScanner(&w)

for fileScanner.Scan() && codeScanner.Scan() {
if strings.Contains(codeScanner.Text(), "etcd:") || strings.Contains(codeScanner.Text(), "minio:") || strings.Contains(codeScanner.Text(), "pulsar:") {
// Skip check of endpoints given by .env
continue
}
if fileScanner.Text() != codeScanner.Text() {
assert.FailNow(t, fmt.Sprintf("configs/milvus.yaml is not consistent with paramtable, file: [%s], code: [%s]. Do not edit milvus.yaml directly.",
fileScanner.Text(), codeScanner.Text()))
}
log.Error("", zap.Any("file", fileScanner.Text()), zap.Any("code", codeScanner.Text()))
}
}
463 changes: 287 additions & 176 deletions configs/milvus.yaml

Large diffs are not rendered by default.

Loading

0 comments on commit ce53e79

Please sign in to comment.