Skip to content

Commit

Permalink
[patch] bugfix lb-gateway's Insert rpc nil pointer panic
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Feb 3, 2021
1 parent c1c6dc0 commit 7b8e222
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 15 deletions.
30 changes: 25 additions & 5 deletions pkg/gateway/backup/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc *
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}

loc, err = s.gateway.Insert(ctx, req, s.copts...)
Expand Down Expand Up @@ -587,7 +591,11 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ
}
return nil, err
}
reqs.Requests[i].Config.SkipStrictExistCheck = true
if reqs.Requests[i] != nil {
reqs.Requests[i].Config.SkipStrictExistCheck = true
} else {
reqs.Requests[i].Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}
ids = append(ids, uuid)
}
Expand Down Expand Up @@ -726,7 +734,11 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Update_Config{SkipStrictExistCheck: true}
}
}

res, err = s.Remove(ctx, &payload.Remove_Request{
Expand Down Expand Up @@ -895,7 +907,11 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ
}
return nil, err
}
vec.Config.SkipStrictExistCheck = true
if vec.Config != nil {
vec.Config.SkipStrictExistCheck = true
} else {
vec.Config = &payload.Update_Config{SkipStrictExistCheck: true}
}
}
ids = append(ids, vec.GetVector().GetId())
ireqs = append(ireqs, &payload.Insert_Request{
Expand Down Expand Up @@ -1251,7 +1267,11 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (loc *
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Remove_Config{SkipStrictExistCheck: true}
}
}

loc, err = s.gateway.Remove(ctx, req, s.copts...)
Expand Down
18 changes: 15 additions & 3 deletions pkg/gateway/filter/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,11 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc *
}
return nil, status.WrapWithAlreadyExists(fmt.Sprintf("Insert API ID %s already exists", vec.GetId()), err, info.Get())
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}
targets := req.GetConfig().GetFilters().GetTargets()
if len(targets) == 0 && len(s.InsertFilters) == 0 {
Expand Down Expand Up @@ -932,7 +936,11 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (loc *
}
return nil, status.WrapWithAlreadyExists(fmt.Sprintf("Update API ID %s already exists", vec.GetId()), err, info.Get())
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Update_Config{SkipStrictExistCheck: true}
}
}
targets := req.GetConfig().GetFilters().GetTargets()
if len(targets) == 0 && len(s.UpdateFilters) == 0 {
Expand Down Expand Up @@ -1069,7 +1077,11 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc *
}
return nil, status.WrapWithAlreadyExists(fmt.Sprintf("Upsert API ID %s already exists", vec.GetId()), err, info.Get())
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Upsert_Config{SkipStrictExistCheck: true}
}
}
targets := req.GetConfig().GetFilters().GetTargets()
if len(targets) == 0 && len(s.UpsertFilters) == 0 {
Expand Down
30 changes: 25 additions & 5 deletions pkg/gateway/lb/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,11 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}

mu := new(sync.Mutex)
Expand Down Expand Up @@ -923,7 +927,11 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ
}
return nil, err
}
reqs.Requests[i].Config.SkipStrictExistCheck = true
if reqs.Requests[i] != nil {
reqs.Requests[i].Config.SkipStrictExistCheck = true
} else {
reqs.Requests[i].Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}
ids = append(ids, uuid)
}
Expand Down Expand Up @@ -1041,7 +1049,11 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Update_Config{SkipStrictExistCheck: true}
}
}

res, err = s.Remove(ctx, &payload.Remove_Request{
Expand Down Expand Up @@ -1209,7 +1221,11 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ
}
return nil, err
}
vec.Config.SkipStrictExistCheck = true
if vec.Config != nil {
vec.Config.SkipStrictExistCheck = true
} else {
vec.Config = &payload.Update_Config{SkipStrictExistCheck: true}
}
}
ids = append(ids, vec.GetVector().GetId())
ireqs = append(ireqs, &payload.Insert_Request{
Expand Down Expand Up @@ -1561,7 +1577,11 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Remove_Config{SkipStrictExistCheck: true}
}
}
var mu sync.Mutex
locs = &payload.Object_Location{
Expand Down
12 changes: 10 additions & 2 deletions pkg/gateway/meta/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,11 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc *
}
return nil, err
}
req.Config.SkipStrictExistCheck = true
if req.Config != nil {
req.Config.SkipStrictExistCheck = true
} else {
req.Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}
uuid := fuid.String()
req.Vector.Id = uuid
Expand Down Expand Up @@ -756,7 +760,11 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ
}
return nil, err
}
reqs.Requests[i].Config.SkipStrictExistCheck = true
if reqs.Requests[i] != nil {
reqs.Requests[i].Config.SkipStrictExistCheck = true
} else {
reqs.Requests[i].Config = &payload.Insert_Config{SkipStrictExistCheck: true}
}
}

uuid := fuid.String()
Expand Down

0 comments on commit 7b8e222

Please sign in to comment.