Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <kpango@vdaas.org>
  • Loading branch information
kpango committed Feb 1, 2021
1 parent f172b77 commit 57269ff
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 46 deletions.
1 change: 0 additions & 1 deletion internal/net/grpc/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func newStatus(code codes.Code, msg string, err error, details ...interface{}) (
return debug
}
if len(details) != 0 {

for _, detail := range details {
switch v := detail.(type) {
case *info.Detail:
Expand Down
2 changes: 1 addition & 1 deletion k8s/external/cassandra/cassandracluster.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
#
# Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org>
#
Expand All @@ -13,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
apiVersion: v1
kind: PersistentVolume
metadata:
Expand Down
16 changes: 12 additions & 4 deletions pkg/gateway/backup/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *
Id: uuid,
})
if err != nil || id == nil || len(id.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(uuid)
if err == nil {
err = errors.ErrObjectIDNotFound(uuid)
}
err = status.WrapWithNotFound(fmt.Sprintf("Update API ID = %v not found", uuid), err,
&errdetails.RequestInfo{
RequestId: uuid,
Expand Down Expand Up @@ -873,7 +875,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ
Id: uuid,
})
if err != nil || id == nil || len(id.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(uuid)
if err == nil {
err = errors.ErrObjectIDNotFound(uuid)
}
err = status.WrapWithNotFound(fmt.Sprintf("MultiUpdate API ID = %v not found", uuid), err,
&errdetails.RequestInfo{
RequestId: uuid,
Expand Down Expand Up @@ -1227,7 +1231,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (loc *
if !req.GetConfig().GetSkipStrictExistCheck() {
id, err := s.Exists(ctx, id)
if err != nil || id == nil || len(id.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(id.GetId())
if err == nil {
err = errors.ErrObjectIDNotFound(id.GetId())
}
err = status.WrapWithNotFound(fmt.Sprintf("Remove API ID = %v not found", id.GetId()), err,
&errdetails.RequestInfo{
RequestId: id.GetId(),
Expand Down Expand Up @@ -1354,7 +1360,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ
if !req.GetConfig().GetSkipStrictExistCheck() {
sid, err := s.Exists(ctx, id)
if err != nil || sid == nil || len(sid.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(id.GetId())
if err == nil {
err = errors.ErrObjectIDNotFound(id.GetId())
}
err = status.WrapWithNotFound(fmt.Sprintf("MultiRemove API ID = %v not found", id.GetId()), err,
&errdetails.RequestInfo{
RequestId: id.GetId(),
Expand Down
25 changes: 17 additions & 8 deletions pkg/gateway/lb/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo
return nil
})
if err != nil || id == nil || id.GetId() == "" {
if err == nil {
err = errors.ErrObjectIDNotFound(id.GetId())
}
err = status.WrapWithNotFound(fmt.Sprintf("Exists API meta %s's uuid not found", meta.GetId()), err,
&errdetails.RequestInfo{
RequestId: meta.GetId(),
Expand All @@ -117,8 +120,7 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo
ResourceName: strings.Join(s.gateway.Addrs(ctx), ", "),
Owner: errdetails.ValdResourceOwner,
Description: err.Error(),
},
meta.GetId(), info.Get())
}, info.Get())
log.Warn(err)
if span != nil {
span.SetStatus(trace.StatusCodeNotFound(err.Error()))
Expand Down Expand Up @@ -410,8 +412,7 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config,
&errdetails.ResourceInfo{
ResourceType: "vald agent server Search API",
ResourceName: strings.Join(s.gateway.Addrs(ctx), ", "),
},
info.Get())
}, info.Get())
log.Warn(err)
return nil, err
}
Expand Down Expand Up @@ -1020,7 +1021,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *
Id: uuid,
})
if err != nil || id == nil || len(id.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(uuid)
if err == nil {
err = errors.ErrObjectIDNotFound(uuid)
}
err = status.WrapWithNotFound(fmt.Sprintf("Update API ID = %v not found", uuid), err,
&errdetails.RequestInfo{
RequestId: uuid,
Expand Down Expand Up @@ -1186,7 +1189,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ
Id: uuid,
})
if err != nil || id == nil || len(id.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(uuid)
if err == nil {
err = errors.ErrObjectIDNotFound(uuid)
}
err = status.WrapWithNotFound(fmt.Sprintf("MultiUpdate API ID = %v not found", uuid), err,
&errdetails.RequestInfo{
RequestId: uuid,
Expand Down Expand Up @@ -1536,7 +1541,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs
if !req.GetConfig().GetSkipStrictExistCheck() {
id, err := s.Exists(ctx, id)
if err != nil || id == nil || len(id.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(id.GetId())
if err == nil {
err = errors.ErrObjectIDNotFound(id.GetId())
}
err = status.WrapWithNotFound(fmt.Sprintf("Remove API ID = %v not found", id.GetId()), err,
&errdetails.RequestInfo{
RequestId: id.GetId(),
Expand Down Expand Up @@ -1665,7 +1672,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ
if !req.GetConfig().GetSkipStrictExistCheck() {
sid, err := s.Exists(ctx, id)
if err != nil || sid == nil || len(sid.GetId()) == 0 {
err = errors.ErrObjectIDNotFound(id.GetId())
if err == nil {
err = errors.ErrObjectIDNotFound(id.GetId())
}
err = status.WrapWithNotFound(fmt.Sprintf("MultiRemove API ID = %v not found", id.GetId()), err,
&errdetails.RequestInfo{
RequestId: id.GetId(),
Expand Down
3 changes: 3 additions & 0 deletions pkg/gateway/meta/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *
}
uuid, err := s.metadata.GetUUID(ctx, meta)
if err != nil || len(uuid) == 0 {
if err == nil {
err = errors.ErrObjectIDNotFound(meta)
}
err = status.WrapWithNotFound(fmt.Sprintf("Update API ID = %v not found", uuid), err,
&errdetails.RequestInfo{
RequestId: uuid,
Expand Down
26 changes: 0 additions & 26 deletions test.sh

This file was deleted.

12 changes: 6 additions & 6 deletions tests/e2e/crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestE2EInsert(t *testing.T) {
if loc == nil {
err := res.GetStatus()
if err != nil {
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(),errdetails.Serialize(err.GetDetails()))
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(), errdetails.Serialize(err.GetDetails()))
}
} else {
t.Logf("returned: %s", loc)
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestE2ESearch(t *testing.T) {
if resp == nil {
err := res.GetStatus()
if err != nil {
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(),errdetails.Serialize(err.GetDetails()))
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(), errdetails.Serialize(err.GetDetails()))
}
} else {
topKIDs := make([]string, len(resp.GetResults()))
Expand Down Expand Up @@ -472,7 +472,7 @@ func TestE2ESearchByID(t *testing.T) {
if resp == nil {
err := res.GetStatus()
if err != nil {
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(),errdetails.Serialize(err.GetDetails()))
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(), errdetails.Serialize(err.GetDetails()))
}
} else {
topKIDs := make([]string, len(resp.GetResults()))
Expand Down Expand Up @@ -559,7 +559,7 @@ func TestE2EGetObject(t *testing.T) {
if resp == nil {
err := res.GetStatus()
if err != nil {
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(),errdetails.Serialize(err.GetDetails()))
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(), errdetails.Serialize(err.GetDetails()))
}
} else {
if !reflect.DeepEqual(res.GetVector(), ds.train[resp.GetId()]) {
Expand Down Expand Up @@ -641,7 +641,7 @@ func TestE2EUpdate(t *testing.T) {
if loc == nil {
err := res.GetStatus()
if err != nil {
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(),errdetails.Serialize(err.GetDetails()))
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(), errdetails.Serialize(err.GetDetails()))
}
} else {
t.Logf("returned: %s", loc)
Expand Down Expand Up @@ -722,7 +722,7 @@ func TestE2ERemove(t *testing.T) {
if loc == nil {
err := res.GetStatus()
if err != nil {
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(),errdetails.Serialize(err.GetDetails()))
t.Errorf("an error returned:\terror: %v\tcode: %d\tmessage: %s\tdetails: %s", err, err.GetCode(), err.GetMessage(), errdetails.Serialize(err.GetDetails()))
}
} else {
t.Logf("returned: %s", loc)
Expand Down

0 comments on commit 57269ff

Please sign in to comment.