Skip to content

Commit

Permalink
More debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Oct 25, 2021
1 parent 7dc5201 commit 4be7fb3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,10 @@ func (s *svc) getPath(ctx context.Context, ref *provider.Reference, keys ...stri
if ref.ResourceId != nil {
req := &provider.StatRequest{Ref: ref, ArbitraryMetadataKeys: keys}
res, err := s.stat(ctx, req)
if (res != nil && res.Status.Code != rpc.Code_CODE_OK) || err != nil {
if err != nil {
return "", status.NewStatusFromErrType(ctx, "getPath ref="+ref.String(), err)
}
if res != nil && res.Status.Code != rpc.Code_CODE_OK {
return "", res.Status
}

Expand Down
19 changes: 16 additions & 3 deletions internal/http/services/owncloud/ocs/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"
"net/http/httptest"

"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"google.golang.org/grpc/metadata"
)
Expand All @@ -31,21 +32,33 @@ func (s *svc) cacheWarmup(w http.ResponseWriter, r *http.Request) {
if s.warmupCacheTracker != nil {
u := ctxpkg.ContextMustGetUser(r.Context())
tkn := ctxpkg.ContextMustGetToken(r.Context())
log := appctx.GetLogger(r.Context())

ctx := context.Background()
ctx = appctx.WithLogger(ctx, log)
ctx = ctxpkg.ContextSetUser(ctx, u)
ctx = ctxpkg.ContextSetToken(ctx, tkn)
ctx = metadata.AppendToOutgoingContext(ctx, ctxpkg.TokenHeader, tkn)
req := r.Clone(ctx)
req.Method = http.MethodGet

req, _ := http.NewRequest("GET", "", nil)
req = req.WithContext(ctx)
req.URL = r.URL

id := u.Id.OpaqueId
if _, err := s.warmupCacheTracker.Get(id); err != nil {
p := httptest.NewRecorder()
_ = s.warmupCacheTracker.Set(id, true)

log.Info().Msgf("cache warmup getting created shares for user %s", id)
req.URL.Path = "/v1.php/apps/files_sharing/api/v1/shares"
s.router.ServeHTTP(p, req)
req.URL.Path = "/v1.php/apps/files_sharing/api/v1/shares?shared_with_me=true"

log.Info().Msgf("cache warmup getting received shares for user %s", id)
req.URL.Path = "/v1.php/apps/files_sharing/api/v1/shares"
q := req.URL.Query()
q.Set("shared_with_me", "true")
q.Set("state", "all")
req.URL.RawQuery = q.Encode()
s.router.ServeHTTP(p, req)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (h *Handler) Init(c *config.Config) {
h.additionalInfoTemplate, _ = template.New("additionalInfo").Parse(c.AdditionalInfoAttribute)

h.userIdentifierCache = ttlcache.NewCache()
_ = h.userIdentifierCache.SetTTL(time.Second * 60)
_ = h.userIdentifierCache.SetTTL(time.Second * 86400)

if h.resourceInfoCacheTTL > 0 {
cwm, err := getCacheWarmupManager(c)
Expand Down Expand Up @@ -512,6 +512,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
// which pending state to list
stateFilter := getStateFilter(r.FormValue("state"))

log := appctx.GetLogger(r.Context())
client, err := pool.GetGatewayServiceClient(h.gatewayAddr)
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error getting grpc gateway client", err)
Expand Down Expand Up @@ -1022,6 +1023,7 @@ func (h *Handler) getResourceInfo(ctx context.Context, client gateway.GatewayAPI
pinfo = infoIf.(*provider.ResourceInfo)
status = &rpc.Status{Code: rpc.Code_CODE_OK}
} else {
logger.Debug().Msgf("cache miss for resource %+v, statting", key)
statReq := &provider.StatRequest{
Ref: ref,
}
Expand Down

0 comments on commit 4be7fb3

Please sign in to comment.