mirror of
https://github.com/rancher/os.git
synced 2025-09-01 06:40:31 +00:00
Add a little logging to make debugging datasources a little easier
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -66,20 +66,21 @@ func Main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func saveCloudConfig() error {
|
func saveCloudConfig() error {
|
||||||
log.Debugf("SaveCloudConfig")
|
log.Infof("SaveCloudConfig")
|
||||||
|
|
||||||
cfg := rancherConfig.LoadConfig()
|
cfg := rancherConfig.LoadConfig()
|
||||||
log.Debugf("init: SaveCloudConfig(pre ApplyNetworkConfig): %#v", cfg.Rancher.Network)
|
log.Debugf("init: SaveCloudConfig(pre ApplyNetworkConfig): %#v", cfg.Rancher.Network)
|
||||||
network.ApplyNetworkConfig(cfg)
|
network.ApplyNetworkConfig(cfg)
|
||||||
|
|
||||||
log.Debugf("datasources that will be consided: %#v", cfg.Rancher.CloudInit.Datasources)
|
log.Infof("datasources that will be consided: %#v", cfg.Rancher.CloudInit.Datasources)
|
||||||
dss := getDatasources(cfg.Rancher.CloudInit.Datasources)
|
dss := getDatasources(cfg.Rancher.CloudInit.Datasources)
|
||||||
if len(dss) == 0 {
|
if len(dss) == 0 {
|
||||||
log.Errorf("currentDatasource - none found")
|
log.Errorf("currentDatasource - none found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
selectDatasource(dss)
|
foundDs := selectDatasource(dss)
|
||||||
|
log.Infof("Cloud-init datasource that was used: %s", foundDs)
|
||||||
|
|
||||||
// Apply any newly detected network config.
|
// Apply any newly detected network config.
|
||||||
cfg = rancherConfig.LoadConfig()
|
cfg = rancherConfig.LoadConfig()
|
||||||
|
@@ -356,6 +356,9 @@ func TestOvfTransport(t *testing.T) {
|
|||||||
|
|
||||||
file.WriteString(tt.document)
|
file.WriteString(tt.document)
|
||||||
v := NewDatasource(file.Name())
|
v := NewDatasource(file.Name())
|
||||||
|
if v == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
v.urlDownload = fakeDownloader
|
v.urlDownload = fakeDownloader
|
||||||
|
|
||||||
metadata, err := v.FetchMetadata()
|
metadata, err := v.FetchMetadata()
|
||||||
|
23
init/init.go
23
init/init.go
@@ -217,6 +217,15 @@ func setupSharedRoot(c *config.CloudConfig) (*config.CloudConfig, error) {
|
|||||||
return c, mount.MakeShared("/")
|
return c, mount.MakeShared("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PrintConfig() {
|
||||||
|
cfgString, err := config.Export(false, true)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{"err": err}).Error("Error serializing config")
|
||||||
|
} else {
|
||||||
|
log.Debugf("Config: %s", cfgString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func RunInit() error {
|
func RunInit() error {
|
||||||
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
|
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
|
||||||
if isInitrd() {
|
if isInitrd() {
|
||||||
@@ -254,17 +263,9 @@ func RunInit() error {
|
|||||||
}},
|
}},
|
||||||
config.CfgFuncData{"mount OEM", mountOem},
|
config.CfgFuncData{"mount OEM", mountOem},
|
||||||
config.CfgFuncData{"debug save cfg", func(_ *config.CloudConfig) (*config.CloudConfig, error) {
|
config.CfgFuncData{"debug save cfg", func(_ *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
|
PrintConfig()
|
||||||
|
|
||||||
cfg := config.LoadConfig()
|
cfg := config.LoadConfig()
|
||||||
|
|
||||||
if cfg.Rancher.Debug {
|
|
||||||
cfgString, err := config.Export(false, true)
|
|
||||||
if err != nil {
|
|
||||||
log.WithFields(log.Fields{"err": err}).Error("Error serializing config")
|
|
||||||
} else {
|
|
||||||
log.Debugf("Config: %s", cfgString)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}},
|
}},
|
||||||
config.CfgFuncData{"load modules", loadModules},
|
config.CfgFuncData{"load modules", loadModules},
|
||||||
@@ -334,7 +335,7 @@ func RunInit() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("init, runCloudInitServices()")
|
log.Infof("init, runCloudInitServices(%v)", cfg.Rancher.CloudInit.Datasources)
|
||||||
if err := runCloudInitServices(cfg); err != nil {
|
if err := runCloudInitServices(cfg); err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user