mirror of
https://github.com/rancher/os.git
synced 2025-09-01 14:48:55 +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:
@@ -177,7 +177,7 @@ func newCoreServiceProject(cfg *config.CloudConfig, network bool) (*project.Proj
|
||||
|
||||
go func() {
|
||||
for event := range projectEvents {
|
||||
if event.EventType == project.EventContainerStarted && event.ServiceName == "network" {
|
||||
if event.EventType == project.EventContainerStarted && event.ServiceName == "ntp" {
|
||||
network = true
|
||||
}
|
||||
}
|
||||
|
@@ -105,7 +105,7 @@ rancher:
|
||||
io.rancher.os.detach: "false"
|
||||
io.rancher.os.reloadconfig: "true"
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: cloud-init-pre, wait-for-network
|
||||
io.rancher.os.after: cloud-init-pre, wait-for-network, ntp
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
@@ -207,7 +207,7 @@ rancher:
|
||||
image: {{.OS_IMAGES_ROOT}}/os-ntp:{{.VERSION}}{{.SUFFIX}}
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: cloud-init, wait-for-network
|
||||
io.rancher.os.after: wait-for-network
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
|
@@ -196,6 +196,7 @@ if [ "$QEMU" == "1" ]; then
|
||||
CPU="-cpu host"
|
||||
fi
|
||||
exec qemu-system-${QEMUARCH} -serial stdio \
|
||||
-rtc base=utc,clock=host \
|
||||
${KVM_ENABLE} \
|
||||
${CPU} \
|
||||
${machine["$ARCH"]} \
|
||||
|
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