1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 22:32:14 +00:00

Fix problems loading external services on boot (like ubuntu-console or kernel-headers)

On arm64 external services would not load on boot because of DNS i/o timeouts or valid TLS certificates appearing expired or not issued yet (I know that sounds weird).
This commit is contained in:
Ivan Mikushin
2016-03-31 11:07:35 -07:00
parent 95d24ac67d
commit 60e5ff7ede
4 changed files with 15 additions and 4 deletions

View File

@@ -274,6 +274,16 @@ func DirLs(dir string) ([]interface{}, error) {
return result, nil
}
func retryHttp(f func() (*http.Response, error), times int) (resp *http.Response, err error) {
for i := 0; i < times; i++ {
if resp, err = f(); err == nil {
return
}
log.Warnf("Error making HTTP request: %s. Retrying", err)
}
return
}
func LoadResource(location string, network bool, urls []string) ([]byte, error) {
var bytes []byte
err := ErrNotFound
@@ -282,7 +292,7 @@ func LoadResource(location string, network bool, urls []string) ([]byte, error)
if !network {
return nil, ErrNoNetwork
}
resp, err := http.Get(location)
resp, err := retryHttp(func() (*http.Response, error) { return http.Get(location) }, 8)
if err != nil {
return nil, err
}