Skip to content

Commit

Permalink
enhance: the actual number of databases should equal the config value (
Browse files Browse the repository at this point in the history
…#38009)

pr: #38006

Signed-off-by: jaime <[email protected]>
  • Loading branch information
jaime0815 authored Nov 26, 2024
1 parent 0a6cfff commit 1c8f14e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/rootcoord/create_db_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (t *createDatabaseTask) Prepare(ctx context.Context) error {
}

cfgMaxDatabaseNum := Params.RootCoordCfg.MaxDatabaseNum.GetAsInt()
if len(dbs) > cfgMaxDatabaseNum {
if len(dbs) >= cfgMaxDatabaseNum {
return merr.WrapErrDatabaseNumLimitExceeded(cfgMaxDatabaseNum)
}

Expand Down
8 changes: 4 additions & 4 deletions internal/rootcoord/create_db_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/metastore/model"
mockrootcoord "github.com/milvus-io/milvus/internal/rootcoord/mocks"
"github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/paramtable"
)

Expand All @@ -51,9 +52,8 @@ func Test_CreateDBTask_Prepare(t *testing.T) {
t.Run("check database number fail", func(t *testing.T) {
meta := mockrootcoord.NewIMetaTable(t)
cfgMaxDatabaseNum := Params.RootCoordCfg.MaxDatabaseNum.GetAsInt()
len := cfgMaxDatabaseNum + 1
dbs := make([]*model.Database, 0, len)
for i := 0; i < len; i++ {
dbs := make([]*model.Database, 0, cfgMaxDatabaseNum)
for i := 0; i < cfgMaxDatabaseNum; i++ {
dbs = append(dbs, model.NewDefaultDatabase())
}
meta.On("ListDatabases",
Expand All @@ -73,7 +73,7 @@ func Test_CreateDBTask_Prepare(t *testing.T) {
},
}
err := task.Prepare(context.Background())
assert.Error(t, err)
assert.ErrorIs(t, err, merr.ErrDatabaseNumLimitExceeded)
})

t.Run("ok", func(t *testing.T) {
Expand Down

0 comments on commit 1c8f14e

Please sign in to comment.