mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
enhance: use the rate log in the privilege interceptor (#32037)
/kind improvement Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
parent
a0a4ec8b67
commit
420baacb6d
@ -88,10 +88,10 @@ func PrivilegeInterceptor(ctx context.Context, req interface{}) (context.Context
|
||||
return ctx, nil
|
||||
}
|
||||
log := log.Ctx(ctx)
|
||||
log.Debug("PrivilegeInterceptor", zap.String("type", reflect.TypeOf(req).String()))
|
||||
log.RatedDebug(60, "PrivilegeInterceptor", zap.String("type", reflect.TypeOf(req).String()))
|
||||
privilegeExt, err := funcutil.GetPrivilegeExtObj(req)
|
||||
if err != nil {
|
||||
log.Info("GetPrivilegeExtObj err", zap.Error(err))
|
||||
log.RatedInfo(60, "GetPrivilegeExtObj err", zap.Error(err))
|
||||
return ctx, nil
|
||||
}
|
||||
username, err := GetCurUserFromContext(ctx)
|
||||
|
@ -34,17 +34,17 @@ func GetVersion(m proto.GeneratedMessage) (string, error) {
|
||||
func GetPrivilegeExtObj(m proto.GeneratedMessage) (commonpb.PrivilegeExt, error) {
|
||||
_, md := descriptor.MessageDescriptorProto(m)
|
||||
if md == nil {
|
||||
log.Info("MessageDescriptorProto result is nil")
|
||||
log.RatedInfo(60, "MessageDescriptorProto result is nil")
|
||||
return commonpb.PrivilegeExt{}, fmt.Errorf("MessageDescriptorProto result is nil")
|
||||
}
|
||||
|
||||
extObj, err := proto.GetExtension(md.Options, commonpb.E_PrivilegeExtObj)
|
||||
if err != nil {
|
||||
log.Info("GetExtension fail", zap.Error(err))
|
||||
log.RatedInfo(60, "GetExtension fail", zap.Error(err))
|
||||
return commonpb.PrivilegeExt{}, err
|
||||
}
|
||||
privilegeExt := extObj.(*commonpb.PrivilegeExt)
|
||||
log.Debug("GetPrivilegeExtObj success", zap.String("resource_type", privilegeExt.ObjectType.String()), zap.String("resource_privilege", privilegeExt.ObjectPrivilege.String()))
|
||||
log.RatedDebug(60, "GetPrivilegeExtObj success", zap.String("resource_type", privilegeExt.ObjectType.String()), zap.String("resource_privilege", privilegeExt.ObjectPrivilege.String()))
|
||||
return commonpb.PrivilegeExt{
|
||||
ObjectType: privilegeExt.ObjectType,
|
||||
ObjectPrivilege: privilegeExt.ObjectPrivilege,
|
||||
|
Loading…
Reference in New Issue
Block a user