@@ -2924,30 +2924,27 @@ func (c *Core) ListPolicy(ctx context.Context, in *internalpb.ListPolicyRequest)
2924
2924
2925
2925
policies , err := c .meta .ListPolicy (ctx , util .DefaultTenant )
2926
2926
if err != nil {
2927
- errMsg := "fail to list policy"
2928
- ctxLog .Warn (errMsg , zap .Error (err ))
2927
+ ctxLog .Error ("fail to list policy" , zap .Error (err ))
2929
2928
return & internalpb.ListPolicyResponse {
2930
- Status : merr .StatusWithErrorCode (errors . New ( errMsg ), commonpb .ErrorCode_ListPolicyFailure ),
2929
+ Status : merr .StatusWithErrorCode (fmt . Errorf ( "fail to list policy: %s" , err . Error () ), commonpb .ErrorCode_ListPolicyFailure ),
2931
2930
}, nil
2932
2931
}
2933
2932
// expand privilege groups and turn to policies
2934
2933
allGroups , err := c .getDefaultAndCustomPrivilegeGroups (ctx )
2935
2934
if err != nil {
2936
- errMsg := "fail to get privilege groups"
2937
- ctxLog .Warn (errMsg , zap .Error (err ))
2935
+ ctxLog .Error ("fail to get privilege groups" , zap .Error (err ))
2938
2936
return & internalpb.ListPolicyResponse {
2939
- Status : merr .StatusWithErrorCode (errors . New ( errMsg ), commonpb .ErrorCode_ListPolicyFailure ),
2937
+ Status : merr .StatusWithErrorCode (fmt . Errorf ( "fail to get privilege groups: %s" , err . Error () ), commonpb .ErrorCode_ListPolicyFailure ),
2940
2938
}, nil
2941
2939
}
2942
2940
groups := lo .SliceToMap (allGroups , func (group * milvuspb.PrivilegeGroupInfo ) (string , []* milvuspb.PrivilegeEntity ) {
2943
2941
return group .GroupName , group .Privileges
2944
2942
})
2945
2943
expandGrants , err := c .expandPrivilegeGroups (ctx , policies , groups )
2946
2944
if err != nil {
2947
- errMsg := "fail to expand privilege groups"
2948
- ctxLog .Warn (errMsg , zap .Error (err ))
2945
+ ctxLog .Error ("fail to expand privilege groups" , zap .Error (err ))
2949
2946
return & internalpb.ListPolicyResponse {
2950
- Status : merr .StatusWithErrorCode (errors . New ( errMsg ), commonpb .ErrorCode_ListPolicyFailure ),
2947
+ Status : merr .StatusWithErrorCode (fmt . Errorf ( "fail to expand privilege groups: %s" , err . Error () ), commonpb .ErrorCode_ListPolicyFailure ),
2951
2948
}, nil
2952
2949
}
2953
2950
expandPolicies := lo .Map (expandGrants , func (r * milvuspb.GrantEntity , _ int ) string {
@@ -2956,10 +2953,9 @@ func (c *Core) ListPolicy(ctx context.Context, in *internalpb.ListPolicyRequest)
2956
2953
2957
2954
userRoles , err := c .meta .ListUserRole (ctx , util .DefaultTenant )
2958
2955
if err != nil {
2959
- errMsg := "fail to list user-role"
2960
- ctxLog .Warn (errMsg , zap .Any ("in" , in ), zap .Error (err ))
2956
+ ctxLog .Error ("fail to list user-role" , zap .Any ("in" , in ), zap .Error (err ))
2961
2957
return & internalpb.ListPolicyResponse {
2962
- Status : merr .StatusWithErrorCode (errors . New ( errMsg ), commonpb .ErrorCode_ListPolicyFailure ),
2958
+ Status : merr .StatusWithErrorCode (fmt . Errorf ( "fail to list user-role: %s" , err . Error () ), commonpb .ErrorCode_ListPolicyFailure ),
2963
2959
}, nil
2964
2960
}
2965
2961
0 commit comments