mirror of https://github.com/kubernetes/kops.git
http download: set a timeout to avoid hangs
I observed a node failure where we failed to download docker; we need some timeout just to prevent the hang. Two minutes should be plenty for our downloads.
This commit is contained in:
parent
fd841dcd58
commit
7ae4d73b5b
|
|
@ -22,6 +22,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kops/util/pkg/hashing"
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue