1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

fix warning messages

Use log.Warnf instead of log.Infof, and remove redundant `WARNING` prefix.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2015-03-11 08:47:45 +08:00
parent 2772a47519
commit bffe04b582
11 changed files with 28 additions and 28 deletions

View file

@ -897,7 +897,7 @@ func (container *Container) GetSize() (int64, int64) {
) )
if err := container.Mount(); err != nil { 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 return sizeRw, sizeRootfs
} }
defer container.Unmount() defer container.Unmount()
@ -905,7 +905,7 @@ func (container *Container) GetSize() (int64, int64) {
initID := fmt.Sprintf("%s-init", container.ID) initID := fmt.Sprintf("%s-init", container.ID)
sizeRw, err = driver.DiffSize(container.ID, initID) sizeRw, err = driver.DiffSize(container.ID, initID)
if err != nil { 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 // FIXME: GetSize should return an error. Not changing it now in case
// there is a side-effect. // there is a side-effect.
sizeRw = -1 sizeRw = -1
@ -1236,15 +1236,15 @@ func (container *Container) initializeNetworking() error {
// Make sure the config is compatible with the current kernel // Make sure the config is compatible with the current kernel
func (container *Container) verifyDaemonSettings() { func (container *Container) verifyDaemonSettings() {
if container.Config.Memory > 0 && !container.daemon.sysInfo.MemoryLimit { 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 container.Config.Memory = 0
} }
if container.Config.Memory > 0 && !container.daemon.sysInfo.SwapLimit { 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 container.Config.MemorySwap = -1
} }
if container.daemon.sysInfo.IPv4ForwardingDisabled { 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")
} }
} }

View file

@ -1231,11 +1231,11 @@ func checkKernel() error {
// the circumstances of pre-3.8 crashes are clearer. // the circumstances of pre-3.8 crashes are clearer.
// For details see http://github.com/docker/docker/issues/407 // For details see http://github.com/docker/docker/issues/407
if k, err := kernel.GetKernelVersion(); err != nil { if k, err := kernel.GetKernelVersion(); err != nil {
log.Infof("WARNING: %s", err) log.Warnf("%s", err)
} else { } else {
if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 { if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 {
if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" { 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())
} }
} }
} }

View file

@ -261,7 +261,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
log.Debugf("oomKill error %s waitErr %s", oomKill, waitErr) log.Debugf("oomKill error %s waitErr %s", oomKill, waitErr)
} else { } 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 <-waitLock

View file

@ -155,7 +155,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
oomKillNotification, err := cont.NotifyOOM() oomKillNotification, err := cont.NotifyOOM()
if err != nil { if err != nil {
oomKillNotification = 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 waitF := p.Wait
if nss := cont.Config().Namespaces; nss.Contains(configs.NEWPID) { if nss := cont.Config().Namespaces; nss.Contains(configs.NEWPID) {

View file

@ -216,7 +216,7 @@ func (a *Driver) Remove(id string) error {
defer a.Unlock() defer a.Unlock()
if a.active[id] != 0 { 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 // Make sure the dir is umounted first

View file

@ -9,7 +9,7 @@ import (
func Unmount(target string) error { func Unmount(target string) error {
if err := exec.Command("auplink", target, "flush").Run(); err != nil { 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 { if err := syscall.Unmount(target, 0); err != nil {
return err return err

View file

@ -347,7 +347,7 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo)
} }
if dinfo.DeviceId > MaxDeviceId { if dinfo.DeviceId > MaxDeviceId {
log.Errorf("Warning: Ignoring Invalid DeviceId=%d", dinfo.DeviceId) log.Errorf("Ignoring Invalid DeviceId=%d", dinfo.DeviceId)
return nil return nil
} }
@ -554,7 +554,7 @@ func (devices *DeviceSet) createRegisterDevice(hash string) (*DevInfo, error) {
// happen. Now we have a mechianism to find // happen. Now we have a mechianism to find
// a free device Id. So something is not right. // a free device Id. So something is not right.
// Give a warning and continue. // 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() deviceId, err = devices.getNextFreeDeviceId()
if err != nil { if err != nil {
return nil, err return nil, err
@ -606,7 +606,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf
// happen. Now we have a mechianism to find // happen. Now we have a mechianism to find
// a free device Id. So something is not right. // a free device Id. So something is not right.
// Give a warning and continue. // 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() deviceId, err = devices.getNextFreeDeviceId()
if err != nil { if err != nil {
return err return err
@ -852,18 +852,18 @@ func (devices *DeviceSet) rollbackTransaction() error {
// closed. In that case this call will fail. Just leave a message // closed. In that case this call will fail. Just leave a message
// in case of failure. // in case of failure.
if err := devicemapper.DeleteDevice(devices.getPoolDevName(), devices.DeviceId); err != nil { 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} dinfo := &DevInfo{Hash: devices.DeviceIdHash}
if err := devices.removeMetadata(dinfo); err != nil { 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 { } else {
devices.markDeviceIdFree(devices.DeviceId) devices.markDeviceIdFree(devices.DeviceId)
} }
if err := devices.removeTransactionMetaData(); err != nil { 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 return nil
@ -883,7 +883,7 @@ func (devices *DeviceSet) processPendingTransaction() error {
// If open transaction Id is less than pool transaction Id, something // If open transaction Id is less than pool transaction Id, something
// is wrong. Bail out. // is wrong. Bail out.
if devices.OpenTransactionId < devices.TransactionId { 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 return nil
} }
@ -963,7 +963,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
// https://github.com/docker/docker/issues/4036 // https://github.com/docker/docker/issues/4036
if supported := devicemapper.UdevSetSyncSupport(true); !supported { 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()) 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, // Wait for the unmount to be effective,
// by watching the value of Info.OpenCount for the device // by watching the value of Info.OpenCount for the device
if err := devices.waitClose(info); err != nil { 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()) devinfo, err := devicemapper.GetInfo(info.Name())
@ -1584,7 +1584,7 @@ func (devices *DeviceSet) getUnderlyingAvailableSpace(loopFile string) (uint64,
buf := new(syscall.Statfs_t) buf := new(syscall.Statfs_t)
err := syscall.Statfs(loopFile, buf) err := syscall.Statfs(loopFile, buf)
if err != nil { 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 0, err
} }
return buf.Bfree * uint64(buf.Bsize), nil return buf.Bfree * uint64(buf.Bsize), nil
@ -1594,7 +1594,7 @@ func (devices *DeviceSet) isRealFile(loopFile string) (bool, error) {
if loopFile != "" { if loopFile != "" {
fi, err := os.Stat(loopFile) fi, err := os.Stat(loopFile)
if err != nil { 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 false, err
} }
return fi.Mode().IsRegular(), nil return fi.Mode().IsRegular(), nil

View file

@ -164,7 +164,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
func (d *Driver) Put(id string) error { func (d *Driver) Put(id string) error {
err := d.DeviceSet.UnmountDevice(id) err := d.DeviceSet.UnmountDevice(id)
if err != nil { if err != nil {
log.Errorf("Warning: error unmounting device %s: %s", id, err) log.Errorf("Error unmounting device %s: %s", id, err)
} }
return err return err
} }

View file

@ -184,6 +184,6 @@ func checkPriorDriver(name, root string) {
} }
} }
if len(priorDrivers) > 0 { 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, ","))
} }
} }

View file

@ -58,7 +58,7 @@ func TestJobStderrString(t *testing.T) {
eng := New() eng := New()
// FIXME: test multiple combinations of output and status // FIXME: test multiple combinations of output and status
eng.Register("say_something_in_stderr", func(job *Job) 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 return StatusOK
}) })

View file

@ -20,20 +20,20 @@ func New(quiet bool) *SysInfo {
sysInfo := &SysInfo{} sysInfo := &SysInfo{}
if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil { if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil {
if !quiet { if !quiet {
log.Printf("WARNING: %s\n", err) log.Warnf("%s", err)
} }
} else { } else {
_, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes")) _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes"))
_, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes"))
sysInfo.MemoryLimit = err1 == nil && err2 == nil sysInfo.MemoryLimit = err1 == nil && err2 == nil
if !sysInfo.MemoryLimit && !quiet { 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")) _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes"))
sysInfo.SwapLimit = err == nil sysInfo.SwapLimit = err == nil
if !sysInfo.SwapLimit && !quiet { 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.")
} }
} }