Skip to content

Commit

Permalink
incorporate review
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jul 7, 2021
1 parent e8d8b4b commit cec7bed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ func (s *svc) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSp
uniqueSpaces := map[string]*provider.StorageSpace{}
for i := range providers {
if errors[i] != nil {
log.Debug().Err(errors[i]).Msg("skipping provider")
continue
if len(providers) > 1 {
log.Debug().Err(errors[i]).Msg("skipping provider")
continue
}
return &provider.ListStorageSpacesResponse{
Status: status.NewStatusFromErrType(ctx, "error listing space", errors[i]),
}, nil
}
for j := range spacesFromProviders[i] {
uniqueSpaces[spacesFromProviders[i][j].Id.OpaqueId] = spacesFromProviders[i][j]
Expand All @@ -207,6 +212,11 @@ func (s *svc) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSp
for spaceID := range uniqueSpaces {
spaces = append(spaces, uniqueSpaces[spaceID])
}
if len(spaces) == 0 {
return &provider.ListStorageSpacesResponse{
Status: status.NewNotFound(ctx, "space not found"),
}, nil
}

return &provider.ListStorageSpacesResponse{
Status: status.NewOK(ctx),
Expand Down
3 changes: 3 additions & 0 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ func hasNodeID(s *provider.StorageSpace) bool {
}

func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSpacesRequest) (*provider.ListStorageSpacesResponse, error) {
log := appctx.GetLogger(ctx)
spaces, err := s.storage.ListStorageSpaces(ctx, req.Filters)
if err != nil {
var st *rpc.Status
Expand Down Expand Up @@ -461,6 +462,8 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
if spaces[i].Root.StorageId == "" {
spaces[i].Root.StorageId = s.mountID
}
} else if spaces[i].Id == nil || spaces[i].Id.OpaqueId == "" {
log.Warn().Str("service", "storageprovider").Str("driver", s.conf.Driver).Interface("space", spaces[i]).Msg("space is missing space id and root id")
}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
// do not list shares as spaces for the owner
continue
}
space.Name = n.Name
} else {
space.Name = "root" // do not expose the id as name, this is the root of a space
// TODO read from extended attribute for project / group spaces
Expand Down

0 comments on commit cec7bed

Please sign in to comment.