diff --git a/cmd/cloudinit/authorize_ssh_keys.go b/cmd/cloudinit/authorize_ssh_keys.go index dccfbc90..52946129 100644 --- a/cmd/cloudinit/authorize_ssh_keys.go +++ b/cmd/cloudinit/authorize_ssh_keys.go @@ -14,7 +14,7 @@ func authorizeSSHKeys(user string, authorizedKeys []string, name string) { cmd.Stderr = os.Stderr err := cmd.Run() if err != nil { - log.Fatal(err.Error()) + log.WithFields(log.Fields{"err": err, "user": user, "auth_key": authorizedKey}).Error("Error updating SSH authorized_keys") } } } diff --git a/cmd/cloudinit/cloudinit.go b/cmd/cloudinit/cloudinit.go index 048778d2..7a076cc6 100644 --- a/cmd/cloudinit/cloudinit.go +++ b/cmd/cloudinit/cloudinit.go @@ -100,7 +100,8 @@ func saveFiles(cloudConfigBytes, scriptBytes []byte, metadata datasource.Metadat func currentDatasource() (datasource.Datasource, error) { cfg, err := rancherConfig.LoadConfig() if err != nil { - log.Fatalf("Failed to read rancher config %v", err) + log.WithFields(log.Fields{"err": err}).Error("Failed to read rancher config") + return nil, err } dss := getDatasources(cfg) @@ -275,7 +276,7 @@ func executeCloudConfig() error { if cc.Hostname != "" { //set hostname if err := hostname.SetHostname(cc.Hostname); err != nil { - log.Fatal(err) + log.WithFields(log.Fields{"err": err, "hostname": cc.Hostname}).Error("Error setting hostname") } } @@ -297,7 +298,8 @@ func executeCloudConfig() error { f := system.File{File: file} fullPath, err := system.WriteFile(&f, "/") if err != nil { - log.Fatal(err) + log.WithFields(log.Fields{"err": err, "path": fullPath}).Error("Error writing file") + continue } log.Printf("Wrote file %s to filesystem", fullPath) }