Remove trailing newline from wwlog
I noticed that some wwlog calls included a trailing newline, but others did not. I tested both in isolation and discovered that the behavior was consistent regardless of whether a trailing newline was included. I further confirmed in code that wwlog appends a trailing newline automatically if it is not present; so a trailing newline is unnecessary in individual calls. This commit removes trailing newlines from all calls to make them consistent. It also replaces two calls to wwlog.Printf. (see #534) Signed-off-by: Jonathon Anderson <janderson@ciq.co>
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func runContainedCmd(args []string) error {
|
||||
wwlog.Verbose("Running contained command: %s\n", args[1:])
|
||||
wwlog.Verbose("Running contained command: %s", args[1:])
|
||||
c := exec.Command("/proc/self/exe", append([]string{"container", "exec", "__child"}, args...)...)
|
||||
|
||||
c.SysProcAttr = &syscall.SysProcAttr{
|
||||
@@ -41,7 +41,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var allargs []string
|
||||
|
||||
if !container.ValidSource(containerName) {
|
||||
wwlog.Error("Unknown Warewulf container: %s\n", containerName)
|
||||
wwlog.Error("Unknown Warewulf container: %s", containerName)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -57,20 +57,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
|
||||
unixStat = fileStat.Sys().(*syscall.Stat_t)
|
||||
groupTime := time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))
|
||||
wwlog.Debug("passwd: %v\n", passwdTime)
|
||||
wwlog.Debug("group: %v\n", groupTime)
|
||||
wwlog.Debug("passwd: %v", passwdTime)
|
||||
wwlog.Debug("group: %v", groupTime)
|
||||
|
||||
err := runContainedCmd(allargs)
|
||||
if err != nil {
|
||||
wwlog.Error("Failed executing container command: %s\n", err)
|
||||
wwlog.Error("Failed executing container command: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if util.IsFile(path.Join(container.RootFsDir(allargs[0]), "/etc/warewulf/container_exit.sh")) {
|
||||
wwlog.Verbose("Found clean script: /etc/warewulf/container_exit.sh\n")
|
||||
wwlog.Verbose("Found clean script: /etc/warewulf/container_exit.sh")
|
||||
err = runContainedCmd([]string{allargs[0], "/bin/sh", "/etc/warewulf/container_exit.sh"})
|
||||
if err != nil {
|
||||
wwlog.Error("Failed executing exit script: %s\n", err)
|
||||
wwlog.Error("Failed executing exit script: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -79,31 +79,31 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
syncuids := false
|
||||
if passwdTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
|
||||
if !SyncUser {
|
||||
wwlog.Warn("/etc/passwd has been modified, maybe you want to run syncuser\n")
|
||||
wwlog.Warn("/etc/passwd has been modified, maybe you want to run syncuser")
|
||||
}
|
||||
syncuids = true
|
||||
}
|
||||
wwlog.Debug("passwd: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
|
||||
wwlog.Debug("passwd: %v", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
|
||||
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
|
||||
unixStat = fileStat.Sys().(*syscall.Stat_t)
|
||||
if groupTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
|
||||
if !SyncUser {
|
||||
wwlog.Warn("/etc/group has been modified, maybe you want to run syncuser\n")
|
||||
wwlog.Warn("/etc/group has been modified, maybe you want to run syncuser")
|
||||
}
|
||||
syncuids = true
|
||||
}
|
||||
wwlog.Debug("group: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
|
||||
wwlog.Debug("group: %v", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
|
||||
if syncuids && SyncUser {
|
||||
err = container.SyncUids(containerName, true)
|
||||
if err != nil {
|
||||
wwlog.Error("Error in user sync, fix error and run 'syncuser' manually, but trying to build container: %s\n", err)
|
||||
wwlog.Error("Error in user sync, fix error and run 'syncuser' manually, but trying to build container: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("Rebuilding container...\n")
|
||||
err = container.Build(containerName, false)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not build container %s: %s\n", containerName, err)
|
||||
wwlog.Error("Could not build container %s: %s", containerName, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user