Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log failures with consistent-hash mode and indicate we're falling back #118

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/download/consistent_hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ func (m *ConsistentHashingMode) Fetch(ctx context.Context, urlString string) (io
// this will use the fallback strategy. This is a case where the whole file will use the fallback
// strategy.
if errors.Is(firstReqResult.err, client.ErrStrategyFallback) {
// TODO(morgan): we should indicate the fallback strategy we're using in the logs
logger.Info().
Str("url", urlString).
Str("type", "file").
Err(err).
Msg("consistent hash fallback")
return m.FallbackStrategy.Fetch(ctx, urlString)
}
return nil, -1, firstReqResult.err
Expand Down Expand Up @@ -215,6 +221,12 @@ func (m *ConsistentHashingMode) Fetch(ctx context.Context, urlString string) (io
// this will use the fallback strategy. This is a case where the whole file will perform the fall-back
// for the specified chunk instead of the whole file.
if errors.Is(err, client.ErrStrategyFallback) {
// TODO(morgan): we should indicate the fallback strategy we're using in the logs
logger.Info().
Str("url", urlString).
Str("type", "chunk").
Err(err).
Msg("consistent hash fallback")
resp, err = m.FallbackStrategy.DoRequest(ctx, chunkStart, chunkEnd, urlString)
}
if err != nil {
Expand Down