Skip to content

Commit

Permalink
Revert "refactor agent error not to wrap with details for performance…
Browse files Browse the repository at this point in the history
… issue (#2154)"

This reverts commit bb04cb2.
  • Loading branch information
ykadowak committed Nov 30, 2023
1 parent 36c875a commit d945ba9
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pkg/agent/core/ngt/handler/grpc/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/vdaas/vald/apis/grpc/v1/payload"
"github.com/vdaas/vald/apis/grpc/v1/vald"
"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/info"
"github.com/vdaas/vald/internal/log"
"github.com/vdaas/vald/internal/net/grpc"
"github.com/vdaas/vald/internal/net/grpc/codes"
Expand Down Expand Up @@ -66,7 +67,17 @@ func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *paylo
return nil, err
}
if _, ok := s.ngt.Exists(uuid); !ok {
err = status.New(codes.NotFound, errors.ErrObjectIDNotFound(uid.GetId()).Error()).Err()
err = errors.ErrObjectIDNotFound(uid.GetId())
err = status.WrapWithNotFound(fmt.Sprintf("Exists API meta %s's uuid not found", uid.GetId()), err,
&errdetails.RequestInfo{
RequestId: uid.GetId(),
ServingData: errdetails.Serialize(uid),
},
&errdetails.ResourceInfo{
ResourceType: ngtResourceType + "/ngt.Exists",
ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip),
},
uid.GetId())
if span != nil {
span.RecordError(err)
span.SetAttributes(trace.StatusCodeNotFound(err.Error())...)
Expand Down Expand Up @@ -114,7 +125,16 @@ func (s *server) GetObject(ctx context.Context, id *payload.Object_VectorRequest
}
vec, ts, err := s.ngt.GetObject(uuid)
if err != nil || vec == nil {
err = status.New(codes.NotFound, errors.ErrObjectNotFound(err, uuid).Error()).Err()
err = errors.ErrObjectNotFound(err, uuid)
err = status.WrapWithNotFound("GetObject API failed to remove request", err,
&errdetails.RequestInfo{
RequestId: uuid,
ServingData: errdetails.Serialize(id),
},
&errdetails.ResourceInfo{
ResourceType: ngtResourceType + "/ngt.GetObject",
ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip),
}, info.Get())
if span != nil {
span.RecordError(err)
span.SetAttributes(trace.StatusCodeNotFound(err.Error())...)
Expand Down

0 comments on commit d945ba9

Please sign in to comment.