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:
parent
ad64c50cc1
commit
d36d4555aa
@ -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()
|
||||
|
@ -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()
|
||||
|
23
init/init.go
23
init/init.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user