mirror of
https://github.com/rancher/os.git
synced 2025-08-17 14:28:16 +00:00
My first pass at fixing the b2d autoformat
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
1c5d41a56e
commit
a4e77692c4
@ -15,12 +15,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func bootstrapAction(c *cli.Context) error {
|
func bootstrapAction(c *cli.Context) error {
|
||||||
|
log.Debugf("bootstrapAction")
|
||||||
if err := UdevSettle(); err != nil {
|
if err := UdevSettle(); err != nil {
|
||||||
log.Errorf("Failed to run udev settle: %v", err)
|
log.Errorf("Failed to run udev settle: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("bootstrapAction: loadingConfig")
|
||||||
cfg := config.LoadConfig()
|
cfg := config.LoadConfig()
|
||||||
|
|
||||||
|
log.Debugf("bootstrapAction: MdadmScan(%v)", cfg.Rancher.State.MdadmScan)
|
||||||
if cfg.Rancher.State.MdadmScan {
|
if cfg.Rancher.State.MdadmScan {
|
||||||
if err := mdadmScan(); err != nil {
|
if err := mdadmScan(); err != nil {
|
||||||
log.Errorf("Failed to run mdadm scan: %v", err)
|
log.Errorf("Failed to run mdadm scan: %v", err)
|
||||||
@ -28,12 +31,14 @@ func bootstrapAction(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateScript := cfg.Rancher.State.Script
|
stateScript := cfg.Rancher.State.Script
|
||||||
|
log.Debugf("bootstrapAction: stateScript(%v)", stateScript)
|
||||||
if stateScript != "" {
|
if stateScript != "" {
|
||||||
if err := runStateScript(stateScript); err != nil {
|
if err := runStateScript(stateScript); err != nil {
|
||||||
log.Errorf("Failed to run state script: %v", err)
|
log.Errorf("Failed to run state script: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("bootstrapAction: RunCommandSequence(%v)", cfg.Bootcmd)
|
||||||
util.RunCommandSequence(cfg.Bootcmd)
|
util.RunCommandSequence(cfg.Bootcmd)
|
||||||
|
|
||||||
if cfg.Rancher.State.Dev != "" && cfg.Rancher.State.Wait {
|
if cfg.Rancher.State.Dev != "" && cfg.Rancher.State.Wait {
|
||||||
@ -41,12 +46,14 @@ func bootstrapAction(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
autoformatDevices := cfg.Rancher.State.Autoformat
|
autoformatDevices := cfg.Rancher.State.Autoformat
|
||||||
|
log.Debugf("bootstrapAction: Autoformat(%v)", cfg.Rancher.State.Autoformat)
|
||||||
if len(autoformatDevices) > 0 {
|
if len(autoformatDevices) > 0 {
|
||||||
if err := autoformat(autoformatDevices); err != nil {
|
if err := autoformat(autoformatDevices); err != nil {
|
||||||
log.Errorf("Failed to run autoformat: %v", err)
|
log.Errorf("Failed to run autoformat: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("bootstrapAction: udev settle2")
|
||||||
if err := UdevSettle(); err != nil {
|
if err := UdevSettle(); err != nil {
|
||||||
log.Errorf("Failed to run udev settle: %v", err)
|
log.Errorf("Failed to run udev settle: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ func readCmdline() map[interface{}]interface{} {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Config cmdline %s", cmdLine)
|
//log.Debugf("Config cmdline %s", cmdLine)
|
||||||
|
|
||||||
cmdLineObj := parseCmdline(strings.TrimSpace(util.UnescapeKernelParams(string(cmdLine))))
|
cmdLineObj := parseCmdline(strings.TrimSpace(util.UnescapeKernelParams(string(cmdLine))))
|
||||||
|
|
||||||
@ -219,6 +220,10 @@ func WriteToFile(data interface{}, filename string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(filepath.Dir(filename), os.ModeDir|0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return util.WriteFileAtomic(filename, content, 400)
|
return util.WriteFileAtomic(filename, content, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
|
|
||||||
func bootstrapServices(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
func bootstrapServices(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
if util.ResolveDevice(cfg.Rancher.State.Dev) != "" && len(cfg.Bootcmd) == 0 {
|
if util.ResolveDevice(cfg.Rancher.State.Dev) != "" && len(cfg.Bootcmd) == 0 {
|
||||||
|
log.Info("NOT Running Bootstrap")
|
||||||
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
log.Info("Running Bootstrap")
|
log.Info("Running Bootstrap")
|
||||||
@ -56,6 +58,8 @@ func stopDocker(c chan interface{}) error {
|
|||||||
|
|
||||||
func bootstrap(cfg *config.CloudConfig) error {
|
func bootstrap(cfg *config.CloudConfig) error {
|
||||||
log.Info("Launching Bootstrap Docker")
|
log.Info("Launching Bootstrap Docker")
|
||||||
|
log.Infof("bootstrap container: Autoformat(%v)", cfg.Rancher.State.Autoformat)
|
||||||
|
|
||||||
c, err := startDocker(cfg)
|
c, err := startDocker(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
15
init/init.go
15
init/init.go
@ -267,7 +267,17 @@ func RunInit() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfg, nil
|
// save here so the bootstrap service can see it (when booting from iso, its very early)
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
if err := config.Set("rancher.state.autoformat", cfg.Rancher.State.Autoformat); err != nil {
|
||||||
|
log.Errorf("Failed to update rancher.state.autoformat: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config.LoadConfig(), nil
|
||||||
},
|
},
|
||||||
func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
var err error
|
var err error
|
||||||
@ -278,9 +288,6 @@ func RunInit() error {
|
|||||||
return cfg, nil
|
return cfg, nil
|
||||||
},
|
},
|
||||||
func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
if err := os.MkdirAll(config.CloudConfigDir, os.ModeDir|0755); err != nil {
|
|
||||||
log.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.Rancher.CloudInit.Datasources = config.LoadConfigWithPrefix(state).Rancher.CloudInit.Datasources
|
cfg.Rancher.CloudInit.Datasources = config.LoadConfigWithPrefix(state).Rancher.CloudInit.Datasources
|
||||||
if err := config.Set("rancher.cloud_init.datasources", cfg.Rancher.CloudInit.Datasources); err != nil {
|
if err := config.Set("rancher.cloud_init.datasources", cfg.Rancher.CloudInit.Datasources); err != nil {
|
||||||
|
@ -32,6 +32,7 @@ rancher:
|
|||||||
- /lib/firmware:/lib/firmware
|
- /lib/firmware:/lib/firmware
|
||||||
- /usr/bin/ros:/usr/bin/ros:ro
|
- /usr/bin/ros:/usr/bin/ros:ro
|
||||||
- /usr/share/ros:/usr/share/ros:ro
|
- /usr/share/ros:/usr/share/ros:ro
|
||||||
|
- /var/lib/rancher:/var/lib/rancher:ro
|
||||||
cloud_init_services:
|
cloud_init_services:
|
||||||
cloud-init:
|
cloud-init:
|
||||||
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||||
|
@ -2,6 +2,8 @@ package integration
|
|||||||
|
|
||||||
import . "gopkg.in/check.v1"
|
import . "gopkg.in/check.v1"
|
||||||
|
|
||||||
|
// NOTE: the boot2docker magic string/tar file is also used by Docker-machine
|
||||||
|
|
||||||
func (s *QemuSuite) TestBoot2DockerState(c *C) {
|
func (s *QemuSuite) TestBoot2DockerState(c *C) {
|
||||||
s.RunQemu(c, "--fresh", "--b2d")
|
s.RunQemu(c, "--fresh", "--b2d")
|
||||||
s.CheckCall(c, "blkid | grep B2D_STATE")
|
s.CheckCall(c, "blkid | grep B2D_STATE")
|
||||||
@ -12,6 +14,8 @@ func (s *QemuSuite) TestBoot2DockerState(c *C) {
|
|||||||
func (s *QemuSuite) TestIsoBoot2DockerState(c *C) {
|
func (s *QemuSuite) TestIsoBoot2DockerState(c *C) {
|
||||||
s.RunQemu(c, "--fresh", "--b2d", "--iso")
|
s.RunQemu(c, "--fresh", "--b2d", "--iso")
|
||||||
s.CheckCall(c, "blkid | grep B2D_STATE")
|
s.CheckCall(c, "blkid | grep B2D_STATE")
|
||||||
|
s.CheckCall(c, "sudo ros config get rancher.state.dev | grep LABEL=B2D_STATE")
|
||||||
|
s.CheckCall(c, "sudo ros config get rancher.state.autoformat | grep vda")
|
||||||
// And once I make run create a tar file, check that its untarred in the docker user's home dir
|
// And once I make run create a tar file, check that its untarred in the docker user's home dir
|
||||||
// And confirm if it should add to the dir, or replace, i can't remember
|
// And confirm if it should add to the dir, or replace, i can't remember
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user