From bffe04b582d143f074297b260a359dfb54a7763b Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Wed, 11 Mar 2015 08:47:45 +0800 Subject: [PATCH] fix warning messages Use log.Warnf instead of log.Infof, and remove redundant `WARNING` prefix. Signed-off-by: Qiang Huang --- daemon/container.go | 10 +++++----- daemon/daemon.go | 4 ++-- daemon/execdriver/lxc/driver.go | 2 +- daemon/execdriver/native/driver.go | 2 +- daemon/graphdriver/aufs/aufs.go | 2 +- daemon/graphdriver/aufs/mount.go | 2 +- daemon/graphdriver/devmapper/deviceset.go | 22 +++++++++++----------- daemon/graphdriver/devmapper/driver.go | 2 +- daemon/graphdriver/driver.go | 2 +- engine/job_test.go | 2 +- pkg/sysinfo/sysinfo.go | 6 +++--- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/daemon/container.go b/daemon/container.go index a065d00b57..091259258f 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -897,7 +897,7 @@ func (container *Container) GetSize() (int64, int64) { ) if err := container.Mount(); err != nil { - log.Errorf("Warning: failed to compute size of container rootfs %s: %s", container.ID, err) + log.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err) return sizeRw, sizeRootfs } defer container.Unmount() @@ -905,7 +905,7 @@ func (container *Container) GetSize() (int64, int64) { initID := fmt.Sprintf("%s-init", container.ID) sizeRw, err = driver.DiffSize(container.ID, initID) if err != nil { - log.Errorf("Warning: driver %s couldn't return diff size of container %s: %s", driver, container.ID, err) + log.Errorf("Driver %s couldn't return diff size of container %s: %s", driver, container.ID, err) // FIXME: GetSize should return an error. Not changing it now in case // there is a side-effect. sizeRw = -1 @@ -1236,15 +1236,15 @@ func (container *Container) initializeNetworking() error { // Make sure the config is compatible with the current kernel func (container *Container) verifyDaemonSettings() { if container.Config.Memory > 0 && !container.daemon.sysInfo.MemoryLimit { - log.Infof("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.") + log.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.") container.Config.Memory = 0 } if container.Config.Memory > 0 && !container.daemon.sysInfo.SwapLimit { - log.Infof("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.") + log.Warnf("Your kernel does not support swap limit capabilities. Limitation discarded.") container.Config.MemorySwap = -1 } if container.daemon.sysInfo.IPv4ForwardingDisabled { - log.Infof("WARNING: IPv4 forwarding is disabled. Networking will not work") + log.Warnf("IPv4 forwarding is disabled. Networking will not work") } } diff --git a/daemon/daemon.go b/daemon/daemon.go index 7e38966cd3..b54e93da53 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1231,11 +1231,11 @@ func checkKernel() error { // the circumstances of pre-3.8 crashes are clearer. // For details see http://github.com/docker/docker/issues/407 if k, err := kernel.GetKernelVersion(); err != nil { - log.Infof("WARNING: %s", err) + log.Warnf("%s", err) } else { if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 { if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" { - log.Infof("WARNING: You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.8.0.", k.String()) + log.Warnf("You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.8.0.", k.String()) } } } diff --git a/daemon/execdriver/lxc/driver.go b/daemon/execdriver/lxc/driver.go index 54da7160a8..4ca11243c9 100644 --- a/daemon/execdriver/lxc/driver.go +++ b/daemon/execdriver/lxc/driver.go @@ -261,7 +261,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba log.Debugf("oomKill error %s waitErr %s", oomKill, waitErr) } else { - log.Warnf("WARNING: Your kernel does not support OOM notifications: %s", err) + log.Warnf("Your kernel does not support OOM notifications: %s", err) } <-waitLock diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index d31e159704..75f7bb706d 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -155,7 +155,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba oomKillNotification, err := cont.NotifyOOM() if err != nil { oomKillNotification = nil - log.Warnf("WARNING: Your kernel does not support OOM notifications: %s", err) + log.Warnf("Your kernel does not support OOM notifications: %s", err) } waitF := p.Wait if nss := cont.Config().Namespaces; nss.Contains(configs.NEWPID) { diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 22579b8b63..1672d1f5a1 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -216,7 +216,7 @@ func (a *Driver) Remove(id string) error { defer a.Unlock() if a.active[id] != 0 { - log.Errorf("Warning: removing active id %s", id) + log.Errorf("Removing active id %s", id) } // Make sure the dir is umounted first diff --git a/daemon/graphdriver/aufs/mount.go b/daemon/graphdriver/aufs/mount.go index bb935f6919..a3a5a86595 100644 --- a/daemon/graphdriver/aufs/mount.go +++ b/daemon/graphdriver/aufs/mount.go @@ -9,7 +9,7 @@ import ( func Unmount(target string) error { if err := exec.Command("auplink", target, "flush").Run(); err != nil { - log.Errorf("[warning]: couldn't run auplink before unmount: %s", err) + log.Errorf("Couldn't run auplink before unmount: %s", err) } if err := syscall.Unmount(target, 0); err != nil { return err diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index 9d30aee671..686d72b951 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -347,7 +347,7 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo) } if dinfo.DeviceId > MaxDeviceId { - log.Errorf("Warning: Ignoring Invalid DeviceId=%d", dinfo.DeviceId) + log.Errorf("Ignoring Invalid DeviceId=%d", dinfo.DeviceId) return nil } @@ -554,7 +554,7 @@ func (devices *DeviceSet) createRegisterDevice(hash string) (*DevInfo, error) { // happen. Now we have a mechianism to find // a free device Id. So something is not right. // Give a warning and continue. - log.Errorf("Warning: Device Id %d exists in pool but it is supposed to be unused", deviceId) + log.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId) deviceId, err = devices.getNextFreeDeviceId() if err != nil { return nil, err @@ -606,7 +606,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf // happen. Now we have a mechianism to find // a free device Id. So something is not right. // Give a warning and continue. - log.Errorf("Warning: Device Id %d exists in pool but it is supposed to be unused", deviceId) + log.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId) deviceId, err = devices.getNextFreeDeviceId() if err != nil { return err @@ -852,18 +852,18 @@ func (devices *DeviceSet) rollbackTransaction() error { // closed. In that case this call will fail. Just leave a message // in case of failure. if err := devicemapper.DeleteDevice(devices.getPoolDevName(), devices.DeviceId); err != nil { - log.Errorf("Warning: Unable to delete device: %s", err) + log.Errorf("Unable to delete device: %s", err) } dinfo := &DevInfo{Hash: devices.DeviceIdHash} if err := devices.removeMetadata(dinfo); err != nil { - log.Errorf("Warning: Unable to remove metadata: %s", err) + log.Errorf("Unable to remove metadata: %s", err) } else { devices.markDeviceIdFree(devices.DeviceId) } if err := devices.removeTransactionMetaData(); err != nil { - log.Errorf("Warning: Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err) + log.Errorf("Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err) } return nil @@ -883,7 +883,7 @@ func (devices *DeviceSet) processPendingTransaction() error { // If open transaction Id is less than pool transaction Id, something // is wrong. Bail out. if devices.OpenTransactionId < devices.TransactionId { - log.Errorf("Warning: Open Transaction id %d is less than pool transaction id %d", devices.OpenTransactionId, devices.TransactionId) + log.Errorf("Open Transaction id %d is less than pool transaction id %d", devices.OpenTransactionId, devices.TransactionId) return nil } @@ -963,7 +963,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { // https://github.com/docker/docker/issues/4036 if supported := devicemapper.UdevSetSyncSupport(true); !supported { - log.Warnf("WARNING: Udev sync is not supported. This will lead to unexpected behavior, data loss and errors") + log.Warnf("Udev sync is not supported. This will lead to unexpected behavior, data loss and errors") } log.Debugf("devicemapper: udev sync support: %v", devicemapper.UdevSyncSupported()) @@ -1221,7 +1221,7 @@ func (devices *DeviceSet) deactivateDevice(info *DevInfo) error { // Wait for the unmount to be effective, // by watching the value of Info.OpenCount for the device if err := devices.waitClose(info); err != nil { - log.Errorf("Warning: error waiting for device %s to close: %s", info.Hash, err) + log.Errorf("Error waiting for device %s to close: %s", info.Hash, err) } devinfo, err := devicemapper.GetInfo(info.Name()) @@ -1584,7 +1584,7 @@ func (devices *DeviceSet) getUnderlyingAvailableSpace(loopFile string) (uint64, buf := new(syscall.Statfs_t) err := syscall.Statfs(loopFile, buf) if err != nil { - log.Warnf("Warning: Couldn't stat loopfile filesystem %v: %v", loopFile, err) + log.Warnf("Couldn't stat loopfile filesystem %v: %v", loopFile, err) return 0, err } return buf.Bfree * uint64(buf.Bsize), nil @@ -1594,7 +1594,7 @@ func (devices *DeviceSet) isRealFile(loopFile string) (bool, error) { if loopFile != "" { fi, err := os.Stat(loopFile) if err != nil { - log.Warnf("Warning: Couldn't stat loopfile %v: %v", loopFile, err) + log.Warnf("Couldn't stat loopfile %v: %v", loopFile, err) return false, err } return fi.Mode().IsRegular(), nil diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go index 1d3d803e2c..6dd05ca375 100644 --- a/daemon/graphdriver/devmapper/driver.go +++ b/daemon/graphdriver/devmapper/driver.go @@ -164,7 +164,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { func (d *Driver) Put(id string) error { err := d.DeviceSet.UnmountDevice(id) if err != nil { - log.Errorf("Warning: error unmounting device %s: %s", id, err) + log.Errorf("Error unmounting device %s: %s", id, err) } return err } diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index fa2ed2c924..9e7f92a0ed 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -184,6 +184,6 @@ func checkPriorDriver(name, root string) { } } if len(priorDrivers) > 0 { - log.Warnf("graphdriver %s selected. Warning: your graphdriver directory %s already contains data managed by other graphdrivers: %s", name, root, strings.Join(priorDrivers, ",")) + log.Warnf("Graphdriver %s selected. Your graphdriver directory %s already contains data managed by other graphdrivers: %s", name, root, strings.Join(priorDrivers, ",")) } } diff --git a/engine/job_test.go b/engine/job_test.go index 67e723988e..9f8c76095c 100644 --- a/engine/job_test.go +++ b/engine/job_test.go @@ -58,7 +58,7 @@ func TestJobStderrString(t *testing.T) { eng := New() // FIXME: test multiple combinations of output and status eng.Register("say_something_in_stderr", func(job *Job) Status { - job.Errorf("Warning, something might happen\nHere it comes!\nOh no...\nSomething happened\n") + job.Errorf("Something might happen\nHere it comes!\nOh no...\nSomething happened\n") return StatusOK }) diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index 001111f43d..1d540d2e7d 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -20,20 +20,20 @@ func New(quiet bool) *SysInfo { sysInfo := &SysInfo{} if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil { if !quiet { - log.Printf("WARNING: %s\n", err) + log.Warnf("%s", err) } } else { _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes")) _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) sysInfo.MemoryLimit = err1 == nil && err2 == nil if !sysInfo.MemoryLimit && !quiet { - log.Printf("WARNING: Your kernel does not support cgroup memory limit.") + log.Warnf("Your kernel does not support cgroup memory limit.") } _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")) sysInfo.SwapLimit = err == nil if !sysInfo.SwapLimit && !quiet { - log.Printf("WARNING: Your kernel does not support cgroup swap limit.") + log.Warnf("Your kernel does not support cgroup swap limit.") } }