Skip to content

Commit

Permalink
Keep trying
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Nov 22, 2024
1 parent e60a8b1 commit 9e179ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions local_cache/cache_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (lc *LocalCache) LaunchListener(ctx context.Context, egrp *errgroup.Group)
if headerTimeout > 0 {
var cancelReqFunc context.CancelFunc
ctx, cancelReqFunc = context.WithTimeout(ctx, headerTimeout)
ctx = context.WithValue(ctx, contextNameKey, "localCacheHeaderTimeout")
defer cancelReqFunc()
}
reader, err = lc.Get(ctx, path, bearerToken)
Expand Down
2 changes: 1 addition & 1 deletion local_cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestLargeFile(t *testing.T) {

clientConfig := map[string]interface{}{
"Client.MaximumDownloadSpeed": 40 * 1024 * 1024,
"Transport.ResponseHeaderTimeout": "1000s",
"Transport.ResponseHeaderTimeout": "100s",
}
test_utils.InitClient(t, clientConfig)
ft := fed_test_utils.NewFedTest(t, pubOriginCfg)
Expand Down
17 changes: 17 additions & 0 deletions local_cache/local_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ import (
"github.com/pelicanplatform/pelican/utils"
)

type contextKey string

const contextNameKey contextKey = "contextName"

type (
LocalCache struct {
ctx context.Context
Expand Down Expand Up @@ -864,6 +868,19 @@ func (cr *cacheReader) readRaw(ctx context.Context, p []byte) (n int, err error)
}
select {
case <-cr.sc.ctx.Done():

contextName, ok := cr.sc.ctx.Value(contextNameKey).(string)
if !ok {
contextName = "unknown"
}

fields := log.Fields{
"component": "local_cache",
"contextName": contextName,
"error": cr.sc.ctx.Err().Error(),
}
log.WithFields(fields).Debugf("\n\n\nLocal cache header timeout hit\n\n\n")

return 0, cr.sc.ctx.Err()
case availSize, ok := <-cr.status:
cr.status = nil
Expand Down

0 comments on commit 9e179ac

Please sign in to comment.