Browse code

*: fix logrus.Warn[f]

Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/06/12 02:42:38
Showing 8 changed files
... ...
@@ -35,7 +35,7 @@ func (container *Container) Reset(lock bool) {
35 35
 			}()
36 36
 			select {
37 37
 			case <-time.After(loggerCloseTimeout):
38
-				logrus.Warnf("Logger didn't exit in time: logs may be truncated")
38
+				logrus.Warn("Logger didn't exit in time: logs may be truncated")
39 39
 			case <-exit:
40 40
 			}
41 41
 		}
... ...
@@ -153,7 +153,7 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos
153 153
 				con = strings.SplitN(opt, "=", 2)
154 154
 			} else if strings.Contains(opt, ":") {
155 155
 				con = strings.SplitN(opt, ":", 2)
156
-				logrus.Warnf("Security options with `:` as a separator are deprecated and will be completely unsupported in 1.13, use `=` instead.")
156
+				logrus.Warn("Security options with `:` as a separator are deprecated and will be completely unsupported in 1.13, use `=` instead.")
157 157
 			}
158 158
 
159 159
 			if len(con) != 2 {
... ...
@@ -197,7 +197,7 @@ func getBlkioThrottleDevices(devs []*blkiodev.ThrottleDevice) ([]specs.ThrottleD
197 197
 
198 198
 func checkKernelVersion(k, major, minor int) bool {
199 199
 	if v, err := kernel.GetKernelVersion(); err != nil {
200
-		logrus.Warnf("%s", err)
200
+		logrus.Warnf("error getting kernel version: %s", err)
201 201
 	} else {
202 202
 		if kernel.CompareKernelVersion(*v, kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) < 0 {
203 203
 			return false
... ...
@@ -273,13 +273,13 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
273 273
 	}
274 274
 	if resources.Memory > 0 && !sysInfo.MemoryLimit {
275 275
 		warnings = append(warnings, "Your kernel does not support memory limit capabilities. Limitation discarded.")
276
-		logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.")
276
+		logrus.Warn("Your kernel does not support memory limit capabilities. Limitation discarded.")
277 277
 		resources.Memory = 0
278 278
 		resources.MemorySwap = -1
279 279
 	}
280 280
 	if resources.Memory > 0 && resources.MemorySwap != -1 && !sysInfo.SwapLimit {
281 281
 		warnings = append(warnings, "Your kernel does not support swap limit capabilities, memory limited without swap.")
282
-		logrus.Warnf("Your kernel does not support swap limit capabilities, memory limited without swap.")
282
+		logrus.Warn("Your kernel does not support swap limit capabilities, memory limited without swap.")
283 283
 		resources.MemorySwap = -1
284 284
 	}
285 285
 	if resources.Memory > 0 && resources.MemorySwap > 0 && resources.MemorySwap < resources.Memory {
... ...
@@ -290,7 +290,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
290 290
 	}
291 291
 	if resources.MemorySwappiness != nil && *resources.MemorySwappiness != -1 && !sysInfo.MemorySwappiness {
292 292
 		warnings = append(warnings, "Your kernel does not support memory swappiness capabilities, memory swappiness discarded.")
293
-		logrus.Warnf("Your kernel does not support memory swappiness capabilities, memory swappiness discarded.")
293
+		logrus.Warn("Your kernel does not support memory swappiness capabilities, memory swappiness discarded.")
294 294
 		resources.MemorySwappiness = nil
295 295
 	}
296 296
 	if resources.MemorySwappiness != nil {
... ...
@@ -301,7 +301,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
301 301
 	}
302 302
 	if resources.MemoryReservation > 0 && !sysInfo.MemoryReservation {
303 303
 		warnings = append(warnings, "Your kernel does not support memory soft limit capabilities. Limitation discarded.")
304
-		logrus.Warnf("Your kernel does not support memory soft limit capabilities. Limitation discarded.")
304
+		logrus.Warn("Your kernel does not support memory soft limit capabilities. Limitation discarded.")
305 305
 		resources.MemoryReservation = 0
306 306
 	}
307 307
 	if resources.MemoryReservation > 0 && resources.MemoryReservation < linuxMinMemory {
... ...
@@ -312,7 +312,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
312 312
 	}
313 313
 	if resources.KernelMemory > 0 && !sysInfo.KernelMemory {
314 314
 		warnings = append(warnings, "Your kernel does not support kernel memory limit capabilities. Limitation discarded.")
315
-		logrus.Warnf("Your kernel does not support kernel memory limit capabilities. Limitation discarded.")
315
+		logrus.Warn("Your kernel does not support kernel memory limit capabilities. Limitation discarded.")
316 316
 		resources.KernelMemory = 0
317 317
 	}
318 318
 	if resources.KernelMemory > 0 && resources.KernelMemory < linuxMinMemory {
... ...
@@ -320,33 +320,33 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
320 320
 	}
321 321
 	if resources.KernelMemory > 0 && !checkKernelVersion(4, 0, 0) {
322 322
 		warnings = append(warnings, "You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
323
-		logrus.Warnf("You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
323
+		logrus.Warn("You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
324 324
 	}
325 325
 	if resources.OomKillDisable != nil && !sysInfo.OomKillDisable {
326 326
 		// only produce warnings if the setting wasn't to *disable* the OOM Kill; no point
327 327
 		// warning the caller if they already wanted the feature to be off
328 328
 		if *resources.OomKillDisable {
329 329
 			warnings = append(warnings, "Your kernel does not support OomKillDisable, OomKillDisable discarded.")
330
-			logrus.Warnf("Your kernel does not support OomKillDisable, OomKillDisable discarded.")
330
+			logrus.Warn("Your kernel does not support OomKillDisable, OomKillDisable discarded.")
331 331
 		}
332 332
 		resources.OomKillDisable = nil
333 333
 	}
334 334
 
335 335
 	if resources.PidsLimit != 0 && !sysInfo.PidsLimit {
336 336
 		warnings = append(warnings, "Your kernel does not support pids limit capabilities, pids limit discarded.")
337
-		logrus.Warnf("Your kernel does not support pids limit capabilities, pids limit discarded.")
337
+		logrus.Warn("Your kernel does not support pids limit capabilities, pids limit discarded.")
338 338
 		resources.PidsLimit = 0
339 339
 	}
340 340
 
341 341
 	// cpu subsystem checks and adjustments
342 342
 	if resources.CPUShares > 0 && !sysInfo.CPUShares {
343 343
 		warnings = append(warnings, "Your kernel does not support CPU shares. Shares discarded.")
344
-		logrus.Warnf("Your kernel does not support CPU shares. Shares discarded.")
344
+		logrus.Warn("Your kernel does not support CPU shares. Shares discarded.")
345 345
 		resources.CPUShares = 0
346 346
 	}
347 347
 	if resources.CPUPeriod > 0 && !sysInfo.CPUCfsPeriod {
348 348
 		warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.")
349
-		logrus.Warnf("Your kernel does not support CPU cfs period. Period discarded.")
349
+		logrus.Warn("Your kernel does not support CPU cfs period. Period discarded.")
350 350
 		resources.CPUPeriod = 0
351 351
 	}
352 352
 	if resources.CPUPeriod != 0 && (resources.CPUPeriod < 1000 || resources.CPUPeriod > 1000000) {
... ...
@@ -354,7 +354,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
354 354
 	}
355 355
 	if resources.CPUQuota > 0 && !sysInfo.CPUCfsQuota {
356 356
 		warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.")
357
-		logrus.Warnf("Your kernel does not support CPU cfs quota. Quota discarded.")
357
+		logrus.Warn("Your kernel does not support CPU cfs quota. Quota discarded.")
358 358
 		resources.CPUQuota = 0
359 359
 	}
360 360
 	if resources.CPUQuota > 0 && resources.CPUQuota < 1000 {
... ...
@@ -362,14 +362,14 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
362 362
 	}
363 363
 	if resources.CPUPercent > 0 {
364 364
 		warnings = append(warnings, "%s does not support CPU percent. Percent discarded.", runtime.GOOS)
365
-		logrus.Warnf("%s does not support CPU percent. Percent discarded.", runtime.GOOS)
365
+		logrus.Warn("%s does not support CPU percent. Percent discarded.", runtime.GOOS)
366 366
 		resources.CPUPercent = 0
367 367
 	}
368 368
 
369 369
 	// cpuset subsystem checks and adjustments
370 370
 	if (resources.CpusetCpus != "" || resources.CpusetMems != "") && !sysInfo.Cpuset {
371 371
 		warnings = append(warnings, "Your kernel does not support cpuset. Cpuset discarded.")
372
-		logrus.Warnf("Your kernel does not support cpuset. Cpuset discarded.")
372
+		logrus.Warn("Your kernel does not support cpuset. Cpuset discarded.")
373 373
 		resources.CpusetCpus = ""
374 374
 		resources.CpusetMems = ""
375 375
 	}
... ...
@@ -391,7 +391,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
391 391
 	// blkio subsystem checks and adjustments
392 392
 	if resources.BlkioWeight > 0 && !sysInfo.BlkioWeight {
393 393
 		warnings = append(warnings, "Your kernel does not support Block I/O weight. Weight discarded.")
394
-		logrus.Warnf("Your kernel does not support Block I/O weight. Weight discarded.")
394
+		logrus.Warn("Your kernel does not support Block I/O weight. Weight discarded.")
395 395
 		resources.BlkioWeight = 0
396 396
 	}
397 397
 	if resources.BlkioWeight > 0 && (resources.BlkioWeight < 10 || resources.BlkioWeight > 1000) {
... ...
@@ -402,27 +402,27 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
402 402
 	}
403 403
 	if len(resources.BlkioWeightDevice) > 0 && !sysInfo.BlkioWeightDevice {
404 404
 		warnings = append(warnings, "Your kernel does not support Block I/O weight_device.")
405
-		logrus.Warnf("Your kernel does not support Block I/O weight_device. Weight-device discarded.")
405
+		logrus.Warn("Your kernel does not support Block I/O weight_device. Weight-device discarded.")
406 406
 		resources.BlkioWeightDevice = []*pblkiodev.WeightDevice{}
407 407
 	}
408 408
 	if len(resources.BlkioDeviceReadBps) > 0 && !sysInfo.BlkioReadBpsDevice {
409 409
 		warnings = append(warnings, "Your kernel does not support Block read limit in bytes per second.")
410
-		logrus.Warnf("Your kernel does not support Block I/O read limit in bytes per second. --device-read-bps discarded.")
410
+		logrus.Warn("Your kernel does not support Block I/O read limit in bytes per second. --device-read-bps discarded.")
411 411
 		resources.BlkioDeviceReadBps = []*pblkiodev.ThrottleDevice{}
412 412
 	}
413 413
 	if len(resources.BlkioDeviceWriteBps) > 0 && !sysInfo.BlkioWriteBpsDevice {
414 414
 		warnings = append(warnings, "Your kernel does not support Block write limit in bytes per second.")
415
-		logrus.Warnf("Your kernel does not support Block I/O write limit in bytes per second. --device-write-bps discarded.")
415
+		logrus.Warn("Your kernel does not support Block I/O write limit in bytes per second. --device-write-bps discarded.")
416 416
 		resources.BlkioDeviceWriteBps = []*pblkiodev.ThrottleDevice{}
417 417
 	}
418 418
 	if len(resources.BlkioDeviceReadIOps) > 0 && !sysInfo.BlkioReadIOpsDevice {
419 419
 		warnings = append(warnings, "Your kernel does not support Block read limit in IO per second.")
420
-		logrus.Warnf("Your kernel does not support Block I/O read limit in IO per second. -device-read-iops discarded.")
420
+		logrus.Warn("Your kernel does not support Block I/O read limit in IO per second. -device-read-iops discarded.")
421 421
 		resources.BlkioDeviceReadIOps = []*pblkiodev.ThrottleDevice{}
422 422
 	}
423 423
 	if len(resources.BlkioDeviceWriteIOps) > 0 && !sysInfo.BlkioWriteIOpsDevice {
424 424
 		warnings = append(warnings, "Your kernel does not support Block write limit in IO per second.")
425
-		logrus.Warnf("Your kernel does not support Block I/O write limit in IO per second. --device-write-iops discarded.")
425
+		logrus.Warn("Your kernel does not support Block I/O write limit in IO per second. --device-write-iops discarded.")
426 426
 		resources.BlkioDeviceWriteIOps = []*pblkiodev.ThrottleDevice{}
427 427
 	}
428 428
 
... ...
@@ -492,7 +492,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
492 492
 	// ip-forwarding does not affect container with '--net=host' (or '--net=none')
493 493
 	if sysInfo.IPv4ForwardingDisabled && !(hostConfig.NetworkMode.IsHost() || hostConfig.NetworkMode.IsNone()) {
494 494
 		warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.")
495
-		logrus.Warnf("IPv4 forwarding is disabled. Networking will not work")
495
+		logrus.Warn("IPv4 forwarding is disabled. Networking will not work")
496 496
 	}
497 497
 	// check for various conflicting options with user namespaces
498 498
 	if daemon.configStore.RemappedRoot != "" && hostConfig.UsernsMode.IsPrivate() {
... ...
@@ -916,7 +916,7 @@ func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error)
916 916
 		if username == "root" {
917 917
 			// Cannot setup user namespaces with a 1-to-1 mapping; "--root=0:0" is a no-op
918 918
 			// effectively
919
-			logrus.Warnf("User namespaces: root cannot be remapped with itself; user namespaces are OFF")
919
+			logrus.Warn("User namespaces: root cannot be remapped with itself; user namespaces are OFF")
920 920
 			return uidMaps, gidMaps, nil
921 921
 		}
922 922
 		logrus.Infof("User namespaces: ID ranges will be mapped to subuid/subgid ranges of: %s:%s", username, groupname)
... ...
@@ -111,32 +111,32 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
111 111
 
112 112
 	if resources.BlkioWeight > 0 {
113 113
 		warnings = append(warnings, "Windows does not support Block I/O weight. Weight discarded.")
114
-		logrus.Warnf("Windows does not support Block I/O weight. --blkio-weight discarded.")
114
+		logrus.Warn("Windows does not support Block I/O weight. --blkio-weight discarded.")
115 115
 		resources.BlkioWeight = 0
116 116
 	}
117 117
 	if len(resources.BlkioWeightDevice) > 0 {
118 118
 		warnings = append(warnings, "Windows does not support Block I/O weight_device.")
119
-		logrus.Warnf("Windows does not support Block I/O weight_device. --blkio-weight-device discarded.")
119
+		logrus.Warn("Windows does not support Block I/O weight_device. --blkio-weight-device discarded.")
120 120
 		resources.BlkioWeightDevice = []*pblkiodev.WeightDevice{}
121 121
 	}
122 122
 	if len(resources.BlkioDeviceReadBps) > 0 {
123 123
 		warnings = append(warnings, "Windows does not support Block read limit in bytes per second.")
124
-		logrus.Warnf("Windows does not support Block I/O read limit in bytes per second. --device-read-bps discarded.")
124
+		logrus.Warn("Windows does not support Block I/O read limit in bytes per second. --device-read-bps discarded.")
125 125
 		resources.BlkioDeviceReadBps = []*pblkiodev.ThrottleDevice{}
126 126
 	}
127 127
 	if len(resources.BlkioDeviceWriteBps) > 0 {
128 128
 		warnings = append(warnings, "Windows does not support Block write limit in bytes per second.")
129
-		logrus.Warnf("Windows does not support Block I/O write limit in bytes per second. --device-write-bps discarded.")
129
+		logrus.Warn("Windows does not support Block I/O write limit in bytes per second. --device-write-bps discarded.")
130 130
 		resources.BlkioDeviceWriteBps = []*pblkiodev.ThrottleDevice{}
131 131
 	}
132 132
 	if len(resources.BlkioDeviceReadIOps) > 0 {
133 133
 		warnings = append(warnings, "Windows does not support Block read limit in IO per second.")
134
-		logrus.Warnf("Windows does not support Block I/O read limit in IO per second. -device-read-iops discarded.")
134
+		logrus.Warn("Windows does not support Block I/O read limit in IO per second. -device-read-iops discarded.")
135 135
 		resources.BlkioDeviceReadIOps = []*pblkiodev.ThrottleDevice{}
136 136
 	}
137 137
 	if len(resources.BlkioDeviceWriteIOps) > 0 {
138 138
 		warnings = append(warnings, "Windows does not support Block write limit in IO per second.")
139
-		logrus.Warnf("Windows does not support Block I/O write limit in IO per second. --device-write-iops discarded.")
139
+		logrus.Warn("Windows does not support Block I/O write limit in IO per second. --device-write-iops discarded.")
140 140
 		resources.BlkioDeviceWriteIOps = []*pblkiodev.ThrottleDevice{}
141 141
 	}
142 142
 	return warnings, nil
... ...
@@ -1815,7 +1815,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
1815 1815
 
1816 1816
 	if devices.thinPoolDevice == "" {
1817 1817
 		if devices.metadataLoopFile != "" || devices.dataLoopFile != "" {
1818
-			logrus.Warnf("devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section.")
1818
+			logrus.Warn("devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section.")
1819 1819
 		}
1820 1820
 	}
1821 1821
 
... ...
@@ -507,7 +507,7 @@ func (d *Driver) GetCustomImageInfos() ([]CustomImageInfo, error) {
507 507
 
508 508
 		versionData := strings.Split(imageData.Version, ".")
509 509
 		if len(versionData) != 4 {
510
-			logrus.Warn("Could not parse Windows version %s", imageData.Version)
510
+			logrus.Warnf("Could not parse Windows version %s", imageData.Version)
511 511
 		} else {
512 512
 			// Include just major.minor.build, skip the fourth version field, which does not influence
513 513
 			// OS compatibility.
... ...
@@ -86,7 +86,7 @@ func (daemon *Daemon) killWithSignal(container *container.Container, sig int) er
86 86
 		// if container or process not exists, ignore the error
87 87
 		if strings.Contains(err.Error(), "container not found") ||
88 88
 			strings.Contains(err.Error(), "no such process") {
89
-			logrus.Warnf("%s", err.Error())
89
+			logrus.Warnf("container kill failed because of 'container not found' or 'no such process': %s", err.Error())
90 90
 		} else {
91 91
 			return err
92 92
 		}
... ...
@@ -226,14 +226,14 @@ func (r *remote) getLastEventTimestamp() int64 {
226 226
 	f, err := os.Open(r.eventTsPath)
227 227
 	defer f.Close()
228 228
 	if err != nil {
229
-		logrus.Warn("libcontainerd: Unable to access last event ts: %v", err)
229
+		logrus.Warnf("libcontainerd: Unable to access last event ts: %v", err)
230 230
 		return t.Unix()
231 231
 	}
232 232
 
233 233
 	b := make([]byte, fi.Size())
234 234
 	n, err := f.Read(b)
235 235
 	if err != nil || n != len(b) {
236
-		logrus.Warn("libcontainerd: Unable to read last event ts: %v", err)
236
+		logrus.Warnf("libcontainerd: Unable to read last event ts: %v", err)
237 237
 		return t.Unix()
238 238
 	}
239 239
 
... ...
@@ -75,7 +75,7 @@ func checkCgroupMem(cgMounts map[string]string, quiet bool) cgroupMemInfo {
75 75
 	mountPoint, ok := cgMounts["memory"]
76 76
 	if !ok {
77 77
 		if !quiet {
78
-			logrus.Warnf("Your kernel does not support cgroup memory limit")
78
+			logrus.Warn("Your kernel does not support cgroup memory limit")
79 79
 		}
80 80
 		return cgroupMemInfo{}
81 81
 	}
... ...
@@ -90,15 +90,15 @@ func checkCgroupMem(cgMounts map[string]string, quiet bool) cgroupMemInfo {
90 90
 	}
91 91
 	oomKillDisable := cgroupEnabled(mountPoint, "memory.oom_control")
92 92
 	if !quiet && !oomKillDisable {
93
-		logrus.Warnf("Your kernel does not support oom control.")
93
+		logrus.Warn("Your kernel does not support oom control.")
94 94
 	}
95 95
 	memorySwappiness := cgroupEnabled(mountPoint, "memory.swappiness")
96 96
 	if !quiet && !memorySwappiness {
97
-		logrus.Warnf("Your kernel does not support memory swappiness.")
97
+		logrus.Warn("Your kernel does not support memory swappiness.")
98 98
 	}
99 99
 	kernelMemory := cgroupEnabled(mountPoint, "memory.kmem.limit_in_bytes")
100 100
 	if !quiet && !kernelMemory {
101
-		logrus.Warnf("Your kernel does not support kernel memory limit.")
101
+		logrus.Warn("Your kernel does not support kernel memory limit.")
102 102
 	}
103 103
 
104 104
 	return cgroupMemInfo{
... ...
@@ -116,7 +116,7 @@ func checkCgroupCPU(cgMounts map[string]string, quiet bool) cgroupCPUInfo {
116 116
 	mountPoint, ok := cgMounts["cpu"]
117 117
 	if !ok {
118 118
 		if !quiet {
119
-			logrus.Warnf("Unable to find cpu cgroup in mounts")
119
+			logrus.Warn("Unable to find cpu cgroup in mounts")
120 120
 		}
121 121
 		return cgroupCPUInfo{}
122 122
 	}
... ...
@@ -147,7 +147,7 @@ func checkCgroupBlkioInfo(cgMounts map[string]string, quiet bool) cgroupBlkioInf
147 147
 	mountPoint, ok := cgMounts["blkio"]
148 148
 	if !ok {
149 149
 		if !quiet {
150
-			logrus.Warnf("Unable to find blkio cgroup in mounts")
150
+			logrus.Warn("Unable to find blkio cgroup in mounts")
151 151
 		}
152 152
 		return cgroupBlkioInfo{}
153 153
 	}
... ...
@@ -195,7 +195,7 @@ func checkCgroupCpusetInfo(cgMounts map[string]string, quiet bool) cgroupCpusetI
195 195
 	mountPoint, ok := cgMounts["cpuset"]
196 196
 	if !ok {
197 197
 		if !quiet {
198
-			logrus.Warnf("Unable to find cpuset cgroup in mounts")
198
+			logrus.Warn("Unable to find cpuset cgroup in mounts")
199 199
 		}
200 200
 		return cgroupCpusetInfo{}
201 201
 	}