Skip to content

Commit

Permalink
Merge pull request #9136 from justinsb/http_download_timeout
Browse files Browse the repository at this point in the history
http download: set a timeout to avoid hangs
  • Loading branch information
k8s-ci-robot authored May 17, 2020
2 parents fd841dc + 7ae4d73 commit ef5c0de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion upup/pkg/fi/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/http"
"os"
"path"
"time"

"k8s.io/klog"
"k8s.io/kops/util/pkg/hashing"
Expand Down Expand Up @@ -76,7 +77,11 @@ func downloadURLAlways(url string, destPath string, dirMode os.FileMode) error {

klog.Infof("Downloading %q", url)

response, err := http.Get(url)
// Create a client with a shorter timeout
httpClient := http.Client{
Timeout: 2 * time.Minute,
}
response, err := httpClient.Get(url)
if err != nil {
return fmt.Errorf("error doing HTTP fetch of %q: %v", url, err)
}
Expand Down

0 comments on commit ef5c0de

Please sign in to comment.