Skip to content

Commit

Permalink
fix(kv): return not found code when user resource mapping indexed by …
Browse files Browse the repository at this point in the history
…not in source
  • Loading branch information
GeorgeMac committed Feb 12, 2020
1 parent d58957f commit abf5eee
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions kv/urm.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ func (s *Service) findUserResourceMappingsByIndex(ctx context.Context, tx Tx, fi
}

for k, v := cursor.Next(); k != nil && v != nil; k, v = cursor.Next() {
v, err := bkt.Get(v)
nv, err := bkt.Get(v)
if err != nil {
return nil, err
return nil, &influxdb.Error{
Code: influxdb.ENotFound,
Err: err,
}
}

m := &influxdb.UserResourceMapping{}
if err := json.Unmarshal(v, m); err != nil {
if err := json.Unmarshal(nv, m); err != nil {
return nil, CorruptURMError(err)
}

Expand Down Expand Up @@ -531,11 +534,13 @@ func (s *Service) deleteOrgDependentMappings(ctx context.Context, tx Tx, m *infl
return err
}
for _, b := range bs {
if err := s.deleteUserResourceMapping(ctx, tx, influxdb.UserResourceMappingFilter{
filter := influxdb.UserResourceMappingFilter{
ResourceType: influxdb.BucketsResourceType,
ResourceID: b.ID,
UserID: m.UserID,
}); err != nil {
}

if err := s.deleteUserResourceMapping(ctx, tx, filter); err != nil {
if influxdb.ErrorCode(err) == influxdb.ENotFound {
s.log.Info("URM bucket is missing", zap.Stringer("orgID", m.ResourceID))
continue
Expand Down

0 comments on commit abf5eee

Please sign in to comment.