1
0
mirror of https://github.com/rancher/os.git synced 2025-08-30 21:26:09 +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:
Sven Dowideit 2017-07-18 21:52:28 +10:00
parent ad64c50cc1
commit d36d4555aa
3 changed files with 19 additions and 14 deletions

View File

@ -66,20 +66,21 @@ func Main() {
}
func saveCloudConfig() error {
log.Debugf("SaveCloudConfig")
log.Infof("SaveCloudConfig")
cfg := rancherConfig.LoadConfig()
log.Debugf("init: SaveCloudConfig(pre ApplyNetworkConfig): %#v", cfg.Rancher.Network)
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)
if len(dss) == 0 {
log.Errorf("currentDatasource - none found")
return nil
}
selectDatasource(dss)
foundDs := selectDatasource(dss)
log.Infof("Cloud-init datasource that was used: %s", foundDs)
// Apply any newly detected network config.
cfg = rancherConfig.LoadConfig()

View File

@ -356,6 +356,9 @@ func TestOvfTransport(t *testing.T) {
file.WriteString(tt.document)
v := NewDatasource(file.Name())
if v == nil {
continue
}
v.urlDownload = fakeDownloader
metadata, err := v.FetchMetadata()

View File

@ -217,6 +217,15 @@ func setupSharedRoot(c *config.CloudConfig) (*config.CloudConfig, error) {
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 {
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
if isInitrd() {
@ -254,17 +263,9 @@ func RunInit() error {
}},
config.CfgFuncData{"mount OEM", mountOem},
config.CfgFuncData{"debug save cfg", func(_ *config.CloudConfig) (*config.CloudConfig, error) {
PrintConfig()
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
}},
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 {
log.Error(err)
}