Skip to content

Commit

Permalink
fix: return proper error if download attempts time out
Browse files Browse the repository at this point in the history
Fixes #6795

This fixes a problem with Talos being stuck if the download attempts
time out - the returned context.Canceled error was triggering a
different flow which treats sequence take over as a special case, while
there is no other sequence to run.

Correct error should be timeout.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Feb 2, 2023
1 parent 54f7d4c commit af21860
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ func Download(ctx context.Context, endpoint string, opts ...Option) (b []byte, e

dlOpts.Endpoint = endpoint

err = retry.Exponential(180*time.Second, retry.WithUnits(time.Second), retry.WithJitter(time.Second), retry.WithErrorLogging(true)).Retry(func() error {
select {
case <-ctx.Done():
return context.Canceled
default:
}

err = retry.Exponential(
180*time.Second,
retry.WithUnits(time.Second),
retry.WithJitter(time.Second),
retry.WithErrorLogging(true),
).RetryWithContext(ctx, func(ctx context.Context) error {
dlOpts = downloadDefaults()

dlOpts.Endpoint = endpoint
Expand Down

0 comments on commit af21860

Please sign in to comment.