Skip to content

Commit

Permalink
always select next before making calls for propfinds
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Jul 17, 2024
1 parent 11ee452 commit 323f11f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/next-before-making-calls-for-propfind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: always select next before making CS3 calls for propfinds

We now select the next client more often to spread out load

https://github.com/cs3org/reva/pull/4560
18 changes: 8 additions & 10 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,11 @@ func (p *Handler) propfindResponse(ctx context.Context, w http.ResponseWriter, r
}

// TODO this is just a stat -> rename
func (p *Handler) statSpace(ctx context.Context, client gateway.GatewayAPIClient, ref *provider.Reference, metadataKeys, fieldMaskPaths []string) (*provider.ResourceInfo, *rpc.Status, error) {
func (p *Handler) statSpace(ctx context.Context, ref *provider.Reference, metadataKeys, fieldMaskPaths []string) (*provider.ResourceInfo, *rpc.Status, error) {
client, err := p.selector.Next()
if err != nil {
return nil, nil, err
}
req := &provider.StatRequest{
Ref: ref,
ArbitraryMetadataKeys: metadataKeys,
Expand All @@ -542,18 +546,12 @@ func (p *Handler) getResourceInfos(ctx context.Context, w http.ResponseWriter, r
span.SetAttributes(attribute.KeyValue{Key: "depth", Value: attribute.StringValue(depth.String())})
defer span.End()

client, err := p.selector.Next()
if err != nil {
log.Error().Err(err).Msg("error getting grpc client")
w.WriteHeader(http.StatusInternalServerError)
return nil, false, false
}

metadataKeys, fieldMaskPaths := metadataKeys(pf)

// we need to stat all spaces to aggregate the root etag, mtime and size
// TODO cache per space (hah, no longer per user + per space!)
var (
err error
rootInfo *provider.ResourceInfo
mostRecentChildInfo *provider.ResourceInfo
aggregatedChildSize uint64
Expand All @@ -569,7 +567,7 @@ func (p *Handler) getResourceInfos(ctx context.Context, w http.ResponseWriter, r
if err != nil {
continue
}
info, status, err := p.statSpace(ctx, client, &spaceRef, metadataKeys, fieldMaskPaths)
info, status, err := p.statSpace(ctx, &spaceRef, metadataKeys, fieldMaskPaths)
if err != nil || status.GetCode() != rpc.Code_CODE_OK {
continue
}
Expand All @@ -587,7 +585,7 @@ func (p *Handler) getResourceInfos(ctx context.Context, w http.ResponseWriter, r
info = space.RootInfo
} else {
var status *rpc.Status
info, status, err = p.statSpace(ctx, client, spaceRef, metadataKeys, fieldMaskPaths)
info, status, err = p.statSpace(ctx, spaceRef, metadataKeys, fieldMaskPaths)
if err != nil || status.GetCode() != rpc.Code_CODE_OK {
continue
}
Expand Down

0 comments on commit 323f11f

Please sign in to comment.