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 Oct 16, 2024
1 parent a322d4a commit f9b64b2
Show file tree
Hide file tree
Showing 2 changed files with 25 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
30 changes: 20 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 Expand Up @@ -656,6 +654,12 @@ func (p *Handler) getResourceInfos(ctx context.Context, w http.ResponseWriter, r
case spaceInfo.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER && depth == net.DepthOne:
switch {
case strings.HasPrefix(requestPath, spaceInfo.Path) && spaceData.SpaceType != "virtual":
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
}
req := &provider.ListContainerRequest{
Ref: spaceData.Ref,
ArbitraryMetadataKeys: metadataKeys,
Expand Down Expand Up @@ -692,6 +696,12 @@ func (p *Handler) getResourceInfos(ctx context.Context, w http.ResponseWriter, r
if info.Type != provider.ResourceType_RESOURCE_TYPE_CONTAINER || spaceData.SpaceType == "virtual" {
continue
}
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
}
req := &provider.ListContainerRequest{
Ref: &provider.Reference{
ResourceId: spaceInfo.Id,
Expand Down

0 comments on commit f9b64b2

Please sign in to comment.