little-cui commented on a change in pull request #248: optimize quota check log
URL:
https://github.com/apache/incubator-servicecomb-service-center/pull/248#discussion_r161162135
##########
File path: server/service/instances.go
##########
@@ -108,23 +108,23 @@ func (s *InstanceService) Register(ctx context.Context,
in *pb.RegisterInstanceR
var reporter quota.QuotaReporter
if len(oldInstanceId) == 0 {
if !apt.IsSCInstance(ctx) {
- var err error
- var ok bool
- reporter, ok, err =
plugin.Plugins().Quota().Apply4Quotas(ctx, quota.MicroServiceInstanceQuotaType,
domainProject, in.Instance.ServiceId, 1)
+ res :=
quota.NewApplyQuotaRes(quota.MicroServiceInstanceQuotaType, domainProject,
in.Instance.ServiceId, 1)
+ rst := plugin.Plugins().Quota().Apply4Quotas(ctx, res)
+ reporter = rst.Reporter
+ err := rst.Err
if reporter != nil {
defer reporter.Close()
}
if err != nil {
- util.Logger().Errorf(err, "register instance
failed, service %s, operator %s: check apply quota failed.", instanceFlag,
remoteIP)
- return &pb.RegisterInstanceResponse{
- Response:
pb.CreateResponse(scerr.ErrUnavailableQuota, err.Error()),
- }, err
- }
- if !ok {
- util.Logger().Errorf(nil, "register instance
failed, service %s, operator %s: no quota apply.", instanceFlag, remoteIP)
- return &pb.RegisterInstanceResponse{
- Response:
pb.CreateResponse(scerr.ErrNotEnoughQuota, "No quota to create instance."),
- }, nil
+ util.Logger().Errorf(err, "register instance
failed, service %s, operator %s: no quota apply.", instanceFlag, remoteIP)
+ response := &pb.RegisterInstanceResponse{
+ Response: pb.CreateResponse(err.Code,
err.Detail),
+ }
+ if err.InternalError() {
+ response.Response =
pb.CreateResponse(err.Code, err.Error())
Review comment:
????120?response????
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services