mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +08:00
cherry-pick from master: https://github.com/milvus-io/milvus/pull/41251 related: #41250 Signed-off-by: shaoting-huang <shaoting.huang@zilliz.com>
This commit is contained in:
parent
f2a5542996
commit
f047e9cd80
@ -2873,19 +2873,17 @@ func (c *Core) ListPolicy(ctx context.Context, in *internalpb.ListPolicyRequest)
|
|||||||
|
|
||||||
policies, err := c.meta.ListPolicy(ctx, util.DefaultTenant)
|
policies, err := c.meta.ListPolicy(ctx, util.DefaultTenant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := "fail to list policy"
|
ctxLog.Error("fail to list policy", zap.Error(err))
|
||||||
ctxLog.Warn(errMsg, zap.Error(err))
|
|
||||||
return &internalpb.ListPolicyResponse{
|
return &internalpb.ListPolicyResponse{
|
||||||
Status: merr.StatusWithErrorCode(errors.New(errMsg), commonpb.ErrorCode_ListPolicyFailure),
|
Status: merr.StatusWithErrorCode(fmt.Errorf("fail to list policy: %s", err.Error()), commonpb.ErrorCode_ListPolicyFailure),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
// expand privilege groups and turn to policies
|
// expand privilege groups and turn to policies
|
||||||
allGroups, err := c.getDefaultAndCustomPrivilegeGroups(ctx)
|
allGroups, err := c.getDefaultAndCustomPrivilegeGroups(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := "fail to get privilege groups"
|
ctxLog.Error("fail to get privilege groups", zap.Error(err))
|
||||||
ctxLog.Warn(errMsg, zap.Error(err))
|
|
||||||
return &internalpb.ListPolicyResponse{
|
return &internalpb.ListPolicyResponse{
|
||||||
Status: merr.StatusWithErrorCode(errors.New(errMsg), commonpb.ErrorCode_ListPolicyFailure),
|
Status: merr.StatusWithErrorCode(fmt.Errorf("fail to get privilege groups: %s", err.Error()), commonpb.ErrorCode_ListPolicyFailure),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
groups := lo.SliceToMap(allGroups, func(group *milvuspb.PrivilegeGroupInfo) (string, []*milvuspb.PrivilegeEntity) {
|
groups := lo.SliceToMap(allGroups, func(group *milvuspb.PrivilegeGroupInfo) (string, []*milvuspb.PrivilegeEntity) {
|
||||||
@ -2893,10 +2891,9 @@ func (c *Core) ListPolicy(ctx context.Context, in *internalpb.ListPolicyRequest)
|
|||||||
})
|
})
|
||||||
expandGrants, err := c.expandPrivilegeGroups(ctx, policies, groups)
|
expandGrants, err := c.expandPrivilegeGroups(ctx, policies, groups)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := "fail to expand privilege groups"
|
ctxLog.Error("fail to expand privilege groups", zap.Error(err))
|
||||||
ctxLog.Warn(errMsg, zap.Error(err))
|
|
||||||
return &internalpb.ListPolicyResponse{
|
return &internalpb.ListPolicyResponse{
|
||||||
Status: merr.StatusWithErrorCode(errors.New(errMsg), commonpb.ErrorCode_ListPolicyFailure),
|
Status: merr.StatusWithErrorCode(fmt.Errorf("fail to expand privilege groups: %s", err.Error()), commonpb.ErrorCode_ListPolicyFailure),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
expandPolicies := lo.Map(expandGrants, func(r *milvuspb.GrantEntity, _ int) string {
|
expandPolicies := lo.Map(expandGrants, func(r *milvuspb.GrantEntity, _ int) string {
|
||||||
@ -2905,10 +2902,9 @@ func (c *Core) ListPolicy(ctx context.Context, in *internalpb.ListPolicyRequest)
|
|||||||
|
|
||||||
userRoles, err := c.meta.ListUserRole(ctx, util.DefaultTenant)
|
userRoles, err := c.meta.ListUserRole(ctx, util.DefaultTenant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := "fail to list user-role"
|
ctxLog.Error("fail to list user-role", zap.Any("in", in), zap.Error(err))
|
||||||
ctxLog.Warn(errMsg, zap.Any("in", in), zap.Error(err))
|
|
||||||
return &internalpb.ListPolicyResponse{
|
return &internalpb.ListPolicyResponse{
|
||||||
Status: merr.StatusWithErrorCode(errors.New(errMsg), commonpb.ErrorCode_ListPolicyFailure),
|
Status: merr.StatusWithErrorCode(fmt.Errorf("fail to list user-role: %s", err.Error()), commonpb.ErrorCode_ListPolicyFailure),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user