Skip to content

Commit

Permalink
Add a very long overall timeout for Autopilot downloads
Browse files Browse the repository at this point in the history
This will ensure that the download will fail at some point, even if the
remote server is artificially slow.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Sep 23, 2024
1 parent 7f83b8f commit 1a51cce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/autopilot/download/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"hash"
"io"
"path/filepath"
"time"

internalhttp "github.com/k0sproject/k0s/internal/http"
"github.com/k0sproject/k0s/internal/pkg/file"
Expand Down Expand Up @@ -73,6 +74,12 @@ func (d *downloader) Download(ctx context.Context) (err error) {
defer func() { err = errors.Join(err, target.Close()) }()
targets = append(targets, target)

// Set a very long overall download timeout. This will ensure that the
// download will fail at some point, even if the remote server is
// artificially slow.
ctx, cancel := context.WithTimeout(ctx, 6*time.Hour)
defer cancel()

// Download from URL into targets.
var fileName string
if err = internalhttp.Download(ctx, d.config.URL, io.MultiWriter(targets...),
Expand Down

0 comments on commit 1a51cce

Please sign in to comment.