mirror of https://github.com/milvus-io/milvus.git
Fix rootcoord failure to start when reaching the limit of role num (#27361)
Signed-off-by: SimFG <bang.fu@zilliz.com>pull/27351/head
parent
dedb90f85f
commit
9fb4c27a90
|
@ -1225,12 +1225,18 @@ func (mt *MetaTable) CreateRole(tenant string, entity *milvuspb.RoleEntity) erro
|
|||
|
||||
results, err := mt.catalog.ListRole(mt.ctx, tenant, nil, false)
|
||||
if err != nil {
|
||||
log.Error("fail to list roles", zap.Error(err))
|
||||
log.Warn("fail to list roles", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
for _, result := range results {
|
||||
if result.GetRole().GetName() == entity.Name {
|
||||
log.Info("role already exists", zap.String("role", entity.Name))
|
||||
return common.NewIgnorableError(errors.Newf("role [%s] already exists", entity))
|
||||
}
|
||||
}
|
||||
if len(results) >= Params.ProxyCfg.MaxRoleNum.GetAsInt() {
|
||||
errMsg := "unable to create role because the number of roles has reached the limit"
|
||||
log.Error(errMsg, zap.Int("max_role_num", Params.ProxyCfg.MaxRoleNum.GetAsInt()))
|
||||
log.Warn(errMsg, zap.Int("max_role_num", Params.ProxyCfg.MaxRoleNum.GetAsInt()))
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import (
|
|||
pb "github.com/milvus-io/milvus/internal/proto/etcdpb"
|
||||
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
||||
mocktso "github.com/milvus-io/milvus/internal/tso/mocks"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/util"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
|
@ -102,6 +103,11 @@ func TestRbacCreateRole(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
t.Run("role has existed", func(t *testing.T) {
|
||||
err := mt.CreateRole(util.DefaultTenant, &milvuspb.RoleEntity{Name: "role1"})
|
||||
assert.Error(t, err)
|
||||
assert.True(t, common.IsIgnorableError(err))
|
||||
})
|
||||
|
||||
{
|
||||
mockCata := mocks.NewRootCoordCatalog(t)
|
||||
|
|
|
@ -1206,7 +1206,7 @@ func TestCore_Import(t *testing.T) {
|
|||
meta.GetPartitionByNameFunc = func(collID UniqueID, partitionName string, ts Timestamp) (UniqueID, error) {
|
||||
return common.InvalidPartitionID, fmt.Errorf("partition ID not found for partition name '%s'", partitionName)
|
||||
}
|
||||
resp2, err := c.Import(ctx, &milvuspb.ImportRequest{
|
||||
resp2, _ := c.Import(ctx, &milvuspb.ImportRequest{
|
||||
CollectionName: "a-good-name",
|
||||
PartitionName: "a-bad-name",
|
||||
Options: []*commonpb.KeyValuePair{
|
||||
|
|
|
@ -40,7 +40,7 @@ func GetPrivilegeExtObj(m proto.GeneratedMessage) (commonpb.PrivilegeExt, error)
|
|||
|
||||
extObj, err := proto.GetExtension(md.Options, commonpb.E_PrivilegeExtObj)
|
||||
if err != nil {
|
||||
log.Warn("GetExtension fail", zap.Error(err))
|
||||
log.Info("GetExtension fail", zap.Error(err))
|
||||
return commonpb.PrivilegeExt{}, err
|
||||
}
|
||||
privilegeExt := extObj.(*commonpb.PrivilegeExt)
|
||||
|
|
Loading…
Reference in New Issue