mirror of
https://github.com/rancher/os.git
synced 2025-09-04 00:04:25 +00:00
Risky: remove 50s for loop delay on network failure (I think its remplaced by the dhcpcd --wait)
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -208,7 +208,7 @@ func IsLocalOrURL(service string) bool {
|
||||
return isLocal(service) || strings.HasPrefix(service, "http:/") || strings.HasPrefix(service, "https:/")
|
||||
}
|
||||
|
||||
// Check to see if the service definition exists
|
||||
// ValidService checks to see if the service definition exists
|
||||
func ValidService(service string, cfg *config.CloudConfig) bool {
|
||||
services := availableService(cfg)
|
||||
if !IsLocalOrURL(service) && !util.Contains(services, service) {
|
||||
|
53
init/init.go
53
init/init.go
@@ -224,19 +224,20 @@ func RunInit() error {
|
||||
|
||||
boot2DockerEnvironment := false
|
||||
var shouldSwitchRoot bool
|
||||
hypervisor := ""
|
||||
|
||||
configFiles := make(map[string][]byte)
|
||||
|
||||
initFuncs := []config.CfgFuncData{
|
||||
config.CfgFuncData{"preparefs", func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return c, dfs.PrepareFs(&mountConfig)
|
||||
config.CfgFuncData{"preparefs", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return cfg, dfs.PrepareFs(&mountConfig)
|
||||
}},
|
||||
config.CfgFuncData{"save init cmdline", func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
config.CfgFuncData{"save init cmdline", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
// will this be passed to cloud-init-save?
|
||||
cmdLineArgs := strings.Join(os.Args, " ")
|
||||
config.SaveInitCmdline(cmdLineArgs)
|
||||
|
||||
return c, nil
|
||||
return cfg, nil
|
||||
}},
|
||||
config.CfgFuncData{"mount OEM", mountOem},
|
||||
config.CfgFuncData{"debug save cfg", func(_ *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
@@ -294,6 +295,7 @@ func RunInit() error {
|
||||
config.CfgFuncData{"mount and bootstrap", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
var err error
|
||||
cfg, shouldSwitchRoot, err = tryMountAndBootstrap(cfg)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -301,7 +303,7 @@ func RunInit() error {
|
||||
}},
|
||||
config.CfgFuncData{"cloud-init", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
cfg.Rancher.CloudInit.Datasources = config.LoadConfigWithPrefix(state).Rancher.CloudInit.Datasources
|
||||
hypervisor := checkHypervisor(cfg)
|
||||
hypervisor = checkHypervisor(cfg)
|
||||
if hypervisor == "vmware" {
|
||||
// add vmware to the end - we don't want to over-ride an choices the user has made
|
||||
cfg.Rancher.CloudInit.Datasources = append(cfg.Rancher.CloudInit.Datasources, hypervisor)
|
||||
@@ -368,8 +370,12 @@ func RunInit() error {
|
||||
|
||||
return cfg, nil
|
||||
}},
|
||||
config.CfgFuncData{"hypervisor tools", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
// Maybe we could set `rancher.hypervisor_service`, and defer this further?
|
||||
enableHypervisorService(hypervisor)
|
||||
return config.LoadConfig(), nil
|
||||
}},
|
||||
config.CfgFuncData{"b2d Env", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
|
||||
if boot2DockerEnvironment {
|
||||
if err := config.Set("rancher.state.dev", cfg.Rancher.State.Dev); err != nil {
|
||||
log.Errorf("Failed to update rancher.state.dev: %v", err)
|
||||
@@ -381,13 +387,13 @@ func RunInit() error {
|
||||
|
||||
return config.LoadConfig(), nil
|
||||
}},
|
||||
config.CfgFuncData{"preparefs2", func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return c, dfs.PrepareFs(&mountConfig)
|
||||
config.CfgFuncData{"preparefs2", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return cfg, dfs.PrepareFs(&mountConfig)
|
||||
}},
|
||||
config.CfgFuncData{"load modules2", loadModules},
|
||||
config.CfgFuncData{"set proxy env", func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
network.SetProxyEnvironmentVariables(c)
|
||||
return c, nil
|
||||
config.CfgFuncData{"set proxy env", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
network.SetProxyEnvironmentVariables(cfg)
|
||||
return cfg, nil
|
||||
}},
|
||||
config.CfgFuncData{"init SELinux", initializeSelinux},
|
||||
config.CfgFuncData{"setupSharedRoot", setupSharedRoot},
|
||||
@@ -412,24 +418,33 @@ func RunInit() error {
|
||||
}
|
||||
|
||||
func checkHypervisor(cfg *config.CloudConfig) string {
|
||||
hvtools := cpuid.CPU.HypervisorName
|
||||
if hvtools == "" {
|
||||
if cpuid.CPU.HypervisorName == "" {
|
||||
log.Infof("ros init: No Detected Hypervisor")
|
||||
} else {
|
||||
log.Infof("ros init: Detected Hypervisor: %s", cpuid.CPU.HypervisorName)
|
||||
if hvtools == "vmware" {
|
||||
hvtools = "open"
|
||||
}
|
||||
serviceName := hvtools + "-vm-tools"
|
||||
return cpuid.CPU.HypervisorName
|
||||
}
|
||||
|
||||
func enableHypervisorService(hypervisorName string) {
|
||||
if hypervisorName == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if hypervisorName == "vmware" {
|
||||
hypervisorName = "open"
|
||||
}
|
||||
serviceName := hypervisorName + "-vm-tools"
|
||||
// check quickly to see if there is a yml file available
|
||||
cfg := config.LoadConfig()
|
||||
if service.ValidService(serviceName, cfg) {
|
||||
log.Infof("Setting rancher.services_include. %s=true", serviceName)
|
||||
log.Debugf("SVEN Setting rancher.services_include. %s=true", serviceName)
|
||||
if err := config.Set("rancher.services_include."+serviceName, "true"); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
} else {
|
||||
log.Infof("Skipping %s, can't get %s.yml file", serviceName, serviceName)
|
||||
log.Infof("SVEN Skipping %s, can't get %s.yml file", serviceName, serviceName)
|
||||
log.Debugf("SVEN Skipping %s, can't get %s.yml file", serviceName, serviceName)
|
||||
}
|
||||
}
|
||||
return cpuid.CPU.HypervisorName
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 console=tty0 rancher.autologin=ttyS1 rancher.console=ttyS1 console=ttyS0 printk.devkmsg=on ${APPEND}
|
||||
APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 console=tty0 rancher.autologin=ttyS1 printk.devkmsg=on ${APPEND}
|
||||
|
@@ -277,7 +277,7 @@ if [ "$GUICONSOLE" == "" ]; then
|
||||
if [ "$NETCONSOLE" == "1" ]; then
|
||||
# put ttyS1 on port 4444
|
||||
DISPLAY_OPTS="${DISPLAY_OPTS} -serial tcp::4444,server"
|
||||
KERNEL_ARGS="rancher.console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}"
|
||||
KERNEL_ARGS="console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -201,7 +201,7 @@ sudo ros service start network
|
||||
sleep 1
|
||||
ip a
|
||||
echo "==================="
|
||||
sudo ros install --force --no-reboot --device /dev/vda -c config.yml -a "console=ttyS0 rancher.console=ttyS0 rancher.autologin=ttyS0 rancher.console=ttyS1 rancher.autologin=ttyS1 rancher.debug=true"
|
||||
sudo ros install --force --no-reboot --device /dev/vda -c config.yml -a "console=ttyS0 rancher.autologin=ttyS0 console=ttyS1 rancher.autologin=ttyS1 rancher.debug=true"
|
||||
sync
|
||||
`)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||
|
||||
@@ -89,11 +88,15 @@ func loadFromNetwork(location string) ([]byte, error) {
|
||||
SetProxyEnvironmentVariables(cfg)
|
||||
|
||||
var err error
|
||||
for i := 0; i < 300; i++ {
|
||||
// Sven thinks that the dhcpcd --wait we added makes this less necessary
|
||||
//for i := 0; i < 300; i++ {
|
||||
updateDNSCache()
|
||||
|
||||
var resp *http.Response
|
||||
log.Infof("LoadFromNetwork(%s)", location)
|
||||
resp, err = http.Get(location)
|
||||
log.Debugf("LoadFromNetwork(%s) returned %v", resp)
|
||||
log.Debugf("LoadFromNetwork(%s) error %v", err)
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
@@ -109,8 +112,8 @@ func loadFromNetwork(location string) ([]byte, error) {
|
||||
return bytes, nil
|
||||
}
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
// time.Sleep(100 * time.Millisecond)
|
||||
//}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user