Browse code

fix warning messages

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

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>

Qiang Huang authored on 2015/03/11 09:47:45
Showing 11 changed files
... ...
@@ -897,7 +897,7 @@ func (container *Container) GetSize() (int64, int64) {
897 897
 	)
898 898
 
899 899
 	if err := container.Mount(); err != nil {
900
-		log.Errorf("Warning: failed to compute size of container rootfs %s: %s", container.ID, err)
900
+		log.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err)
901 901
 		return sizeRw, sizeRootfs
902 902
 	}
903 903
 	defer container.Unmount()
... ...
@@ -905,7 +905,7 @@ func (container *Container) GetSize() (int64, int64) {
905 905
 	initID := fmt.Sprintf("%s-init", container.ID)
906 906
 	sizeRw, err = driver.DiffSize(container.ID, initID)
907 907
 	if err != nil {
908
-		log.Errorf("Warning: driver %s couldn't return diff size of container %s: %s", driver, container.ID, err)
908
+		log.Errorf("Driver %s couldn't return diff size of container %s: %s", driver, container.ID, err)
909 909
 		// FIXME: GetSize should return an error. Not changing it now in case
910 910
 		// there is a side-effect.
911 911
 		sizeRw = -1
... ...
@@ -1236,15 +1236,15 @@ func (container *Container) initializeNetworking() error {
1236 1236
 // Make sure the config is compatible with the current kernel
1237 1237
 func (container *Container) verifyDaemonSettings() {
1238 1238
 	if container.Config.Memory > 0 && !container.daemon.sysInfo.MemoryLimit {
1239
-		log.Infof("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.")
1239
+		log.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.")
1240 1240
 		container.Config.Memory = 0
1241 1241
 	}
1242 1242
 	if container.Config.Memory > 0 && !container.daemon.sysInfo.SwapLimit {
1243
-		log.Infof("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.")
1243
+		log.Warnf("Your kernel does not support swap limit capabilities. Limitation discarded.")
1244 1244
 		container.Config.MemorySwap = -1
1245 1245
 	}
1246 1246
 	if container.daemon.sysInfo.IPv4ForwardingDisabled {
1247
-		log.Infof("WARNING: IPv4 forwarding is disabled. Networking will not work")
1247
+		log.Warnf("IPv4 forwarding is disabled. Networking will not work")
1248 1248
 	}
1249 1249
 }
1250 1250
 
... ...
@@ -1231,11 +1231,11 @@ func checkKernel() error {
1231 1231
 	// the circumstances of pre-3.8 crashes are clearer.
1232 1232
 	// For details see http://github.com/docker/docker/issues/407
1233 1233
 	if k, err := kernel.GetKernelVersion(); err != nil {
1234
-		log.Infof("WARNING: %s", err)
1234
+		log.Warnf("%s", err)
1235 1235
 	} else {
1236 1236
 		if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 {
1237 1237
 			if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" {
1238
-				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())
1238
+				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())
1239 1239
 			}
1240 1240
 		}
1241 1241
 	}
... ...
@@ -261,7 +261,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
261 261
 		log.Debugf("oomKill error %s waitErr %s", oomKill, waitErr)
262 262
 
263 263
 	} else {
264
-		log.Warnf("WARNING: Your kernel does not support OOM notifications: %s", err)
264
+		log.Warnf("Your kernel does not support OOM notifications: %s", err)
265 265
 	}
266 266
 
267 267
 	<-waitLock
... ...
@@ -155,7 +155,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
155 155
 	oomKillNotification, err := cont.NotifyOOM()
156 156
 	if err != nil {
157 157
 		oomKillNotification = nil
158
-		log.Warnf("WARNING: Your kernel does not support OOM notifications: %s", err)
158
+		log.Warnf("Your kernel does not support OOM notifications: %s", err)
159 159
 	}
160 160
 	waitF := p.Wait
161 161
 	if nss := cont.Config().Namespaces; nss.Contains(configs.NEWPID) {
... ...
@@ -216,7 +216,7 @@ func (a *Driver) Remove(id string) error {
216 216
 	defer a.Unlock()
217 217
 
218 218
 	if a.active[id] != 0 {
219
-		log.Errorf("Warning: removing active id %s", id)
219
+		log.Errorf("Removing active id %s", id)
220 220
 	}
221 221
 
222 222
 	// Make sure the dir is umounted first
... ...
@@ -9,7 +9,7 @@ import (
9 9
 
10 10
 func Unmount(target string) error {
11 11
 	if err := exec.Command("auplink", target, "flush").Run(); err != nil {
12
-		log.Errorf("[warning]: couldn't run auplink before unmount: %s", err)
12
+		log.Errorf("Couldn't run auplink before unmount: %s", err)
13 13
 	}
14 14
 	if err := syscall.Unmount(target, 0); err != nil {
15 15
 		return err
... ...
@@ -347,7 +347,7 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo)
347 347
 	}
348 348
 
349 349
 	if dinfo.DeviceId > MaxDeviceId {
350
-		log.Errorf("Warning: Ignoring Invalid DeviceId=%d", dinfo.DeviceId)
350
+		log.Errorf("Ignoring Invalid DeviceId=%d", dinfo.DeviceId)
351 351
 		return nil
352 352
 	}
353 353
 
... ...
@@ -554,7 +554,7 @@ func (devices *DeviceSet) createRegisterDevice(hash string) (*DevInfo, error) {
554 554
 				// happen. Now we have a mechianism to find
555 555
 				// a free device Id. So something is not right.
556 556
 				// Give a warning and continue.
557
-				log.Errorf("Warning: Device Id %d exists in pool but it is supposed to be unused", deviceId)
557
+				log.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId)
558 558
 				deviceId, err = devices.getNextFreeDeviceId()
559 559
 				if err != nil {
560 560
 					return nil, err
... ...
@@ -606,7 +606,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf
606 606
 				// happen. Now we have a mechianism to find
607 607
 				// a free device Id. So something is not right.
608 608
 				// Give a warning and continue.
609
-				log.Errorf("Warning: Device Id %d exists in pool but it is supposed to be unused", deviceId)
609
+				log.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId)
610 610
 				deviceId, err = devices.getNextFreeDeviceId()
611 611
 				if err != nil {
612 612
 					return err
... ...
@@ -852,18 +852,18 @@ func (devices *DeviceSet) rollbackTransaction() error {
852 852
 	// closed. In that case this call will fail. Just leave a message
853 853
 	// in case of failure.
854 854
 	if err := devicemapper.DeleteDevice(devices.getPoolDevName(), devices.DeviceId); err != nil {
855
-		log.Errorf("Warning: Unable to delete device: %s", err)
855
+		log.Errorf("Unable to delete device: %s", err)
856 856
 	}
857 857
 
858 858
 	dinfo := &DevInfo{Hash: devices.DeviceIdHash}
859 859
 	if err := devices.removeMetadata(dinfo); err != nil {
860
-		log.Errorf("Warning: Unable to remove metadata: %s", err)
860
+		log.Errorf("Unable to remove metadata: %s", err)
861 861
 	} else {
862 862
 		devices.markDeviceIdFree(devices.DeviceId)
863 863
 	}
864 864
 
865 865
 	if err := devices.removeTransactionMetaData(); err != nil {
866
-		log.Errorf("Warning: Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err)
866
+		log.Errorf("Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err)
867 867
 	}
868 868
 
869 869
 	return nil
... ...
@@ -883,7 +883,7 @@ func (devices *DeviceSet) processPendingTransaction() error {
883 883
 	// If open transaction Id is less than pool transaction Id, something
884 884
 	// is wrong. Bail out.
885 885
 	if devices.OpenTransactionId < devices.TransactionId {
886
-		log.Errorf("Warning: Open Transaction id %d is less than pool transaction id %d", devices.OpenTransactionId, devices.TransactionId)
886
+		log.Errorf("Open Transaction id %d is less than pool transaction id %d", devices.OpenTransactionId, devices.TransactionId)
887 887
 		return nil
888 888
 	}
889 889
 
... ...
@@ -963,7 +963,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
963 963
 
964 964
 	// https://github.com/docker/docker/issues/4036
965 965
 	if supported := devicemapper.UdevSetSyncSupport(true); !supported {
966
-		log.Warnf("WARNING: Udev sync is not supported. This will lead to unexpected behavior, data loss and errors")
966
+		log.Warnf("Udev sync is not supported. This will lead to unexpected behavior, data loss and errors")
967 967
 	}
968 968
 	log.Debugf("devicemapper: udev sync support: %v", devicemapper.UdevSyncSupported())
969 969
 
... ...
@@ -1221,7 +1221,7 @@ func (devices *DeviceSet) deactivateDevice(info *DevInfo) error {
1221 1221
 	// Wait for the unmount to be effective,
1222 1222
 	// by watching the value of Info.OpenCount for the device
1223 1223
 	if err := devices.waitClose(info); err != nil {
1224
-		log.Errorf("Warning: error waiting for device %s to close: %s", info.Hash, err)
1224
+		log.Errorf("Error waiting for device %s to close: %s", info.Hash, err)
1225 1225
 	}
1226 1226
 
1227 1227
 	devinfo, err := devicemapper.GetInfo(info.Name())
... ...
@@ -1584,7 +1584,7 @@ func (devices *DeviceSet) getUnderlyingAvailableSpace(loopFile string) (uint64,
1584 1584
 	buf := new(syscall.Statfs_t)
1585 1585
 	err := syscall.Statfs(loopFile, buf)
1586 1586
 	if err != nil {
1587
-		log.Warnf("Warning: Couldn't stat loopfile filesystem %v: %v", loopFile, err)
1587
+		log.Warnf("Couldn't stat loopfile filesystem %v: %v", loopFile, err)
1588 1588
 		return 0, err
1589 1589
 	}
1590 1590
 	return buf.Bfree * uint64(buf.Bsize), nil
... ...
@@ -1594,7 +1594,7 @@ func (devices *DeviceSet) isRealFile(loopFile string) (bool, error) {
1594 1594
 	if loopFile != "" {
1595 1595
 		fi, err := os.Stat(loopFile)
1596 1596
 		if err != nil {
1597
-			log.Warnf("Warning: Couldn't stat loopfile %v: %v", loopFile, err)
1597
+			log.Warnf("Couldn't stat loopfile %v: %v", loopFile, err)
1598 1598
 			return false, err
1599 1599
 		}
1600 1600
 		return fi.Mode().IsRegular(), nil
... ...
@@ -164,7 +164,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
164 164
 func (d *Driver) Put(id string) error {
165 165
 	err := d.DeviceSet.UnmountDevice(id)
166 166
 	if err != nil {
167
-		log.Errorf("Warning: error unmounting device %s: %s", id, err)
167
+		log.Errorf("Error unmounting device %s: %s", id, err)
168 168
 	}
169 169
 	return err
170 170
 }
... ...
@@ -184,6 +184,6 @@ func checkPriorDriver(name, root string) {
184 184
 		}
185 185
 	}
186 186
 	if len(priorDrivers) > 0 {
187
-		log.Warnf("graphdriver %s selected. Warning: your graphdriver directory %s already contains data managed by other graphdrivers: %s", name, root, strings.Join(priorDrivers, ","))
187
+		log.Warnf("Graphdriver %s selected. Your graphdriver directory %s already contains data managed by other graphdrivers: %s", name, root, strings.Join(priorDrivers, ","))
188 188
 	}
189 189
 }
... ...
@@ -58,7 +58,7 @@ func TestJobStderrString(t *testing.T) {
58 58
 	eng := New()
59 59
 	// FIXME: test multiple combinations of output and status
60 60
 	eng.Register("say_something_in_stderr", func(job *Job) Status {
61
-		job.Errorf("Warning, something might happen\nHere it comes!\nOh no...\nSomething happened\n")
61
+		job.Errorf("Something might happen\nHere it comes!\nOh no...\nSomething happened\n")
62 62
 		return StatusOK
63 63
 	})
64 64
 
... ...
@@ -20,20 +20,20 @@ func New(quiet bool) *SysInfo {
20 20
 	sysInfo := &SysInfo{}
21 21
 	if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil {
22 22
 		if !quiet {
23
-			log.Printf("WARNING: %s\n", err)
23
+			log.Warnf("%s", err)
24 24
 		}
25 25
 	} else {
26 26
 		_, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes"))
27 27
 		_, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes"))
28 28
 		sysInfo.MemoryLimit = err1 == nil && err2 == nil
29 29
 		if !sysInfo.MemoryLimit && !quiet {
30
-			log.Printf("WARNING: Your kernel does not support cgroup memory limit.")
30
+			log.Warnf("Your kernel does not support cgroup memory limit.")
31 31
 		}
32 32
 
33 33
 		_, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes"))
34 34
 		sysInfo.SwapLimit = err == nil
35 35
 		if !sysInfo.SwapLimit && !quiet {
36
-			log.Printf("WARNING: Your kernel does not support cgroup swap limit.")
36
+			log.Warnf("Your kernel does not support cgroup swap limit.")
37 37
 		}
38 38
 	}
39 39