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:
12
util/util.go
12
util/util.go
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user