Skip to content

Commit 44ccbb3

Browse files
committed
*: fix logrus.Warn[f]
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent 2a6abf1 commit 44ccbb3

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

container/monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (container *Container) Reset(lock bool) {
3535
}()
3636
select {
3737
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")
3939
case <-exit:
4040
}
4141
}

daemon/daemon_unix.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos
153153
con = strings.SplitN(opt, "=", 2)
154154
} else if strings.Contains(opt, ":") {
155155
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.")
157157
}
158158

159159
if len(con) != 2 {
@@ -197,7 +197,7 @@ func getBlkioThrottleDevices(devs []*blkiodev.ThrottleDevice) ([]specs.ThrottleD
197197

198198
func checkKernelVersion(k, major, minor int) bool {
199199
if v, err := kernel.GetKernelVersion(); err != nil {
200-
logrus.Warnf("%s", err)
200+
logrus.Warnf("error getting kernel version: %s", err)
201201
} else {
202202
if kernel.CompareKernelVersion(*v, kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) < 0 {
203203
return false
@@ -273,13 +273,13 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
273273
}
274274
if resources.Memory > 0 && !sysInfo.MemoryLimit {
275275
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.")
277277
resources.Memory = 0
278278
resources.MemorySwap = -1
279279
}
280280
if resources.Memory > 0 && resources.MemorySwap != -1 && !sysInfo.SwapLimit {
281281
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.")
283283
resources.MemorySwap = -1
284284
}
285285
if resources.Memory > 0 && resources.MemorySwap > 0 && resources.MemorySwap < resources.Memory {
@@ -290,7 +290,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
290290
}
291291
if resources.MemorySwappiness != nil && *resources.MemorySwappiness != -1 && !sysInfo.MemorySwappiness {
292292
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.")
294294
resources.MemorySwappiness = nil
295295
}
296296
if resources.MemorySwappiness != nil {
@@ -301,7 +301,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
301301
}
302302
if resources.MemoryReservation > 0 && !sysInfo.MemoryReservation {
303303
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.")
305305
resources.MemoryReservation = 0
306306
}
307307
if resources.MemoryReservation > 0 && resources.MemoryReservation < linuxMinMemory {
@@ -312,64 +312,64 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
312312
}
313313
if resources.KernelMemory > 0 && !sysInfo.KernelMemory {
314314
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.")
316316
resources.KernelMemory = 0
317317
}
318318
if resources.KernelMemory > 0 && resources.KernelMemory < linuxMinMemory {
319319
return warnings, fmt.Errorf("Minimum kernel memory limit allowed is 4MB")
320320
}
321321
if resources.KernelMemory > 0 && !checkKernelVersion(4, 0, 0) {
322322
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.")
324324
}
325325
if resources.OomKillDisable != nil && !sysInfo.OomKillDisable {
326326
// only produce warnings if the setting wasn't to *disable* the OOM Kill; no point
327327
// warning the caller if they already wanted the feature to be off
328328
if *resources.OomKillDisable {
329329
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.")
331331
}
332332
resources.OomKillDisable = nil
333333
}
334334

335335
if resources.PidsLimit != 0 && !sysInfo.PidsLimit {
336336
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.")
338338
resources.PidsLimit = 0
339339
}
340340

341341
// cpu subsystem checks and adjustments
342342
if resources.CPUShares > 0 && !sysInfo.CPUShares {
343343
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.")
345345
resources.CPUShares = 0
346346
}
347347
if resources.CPUPeriod > 0 && !sysInfo.CPUCfsPeriod {
348348
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.")
350350
resources.CPUPeriod = 0
351351
}
352352
if resources.CPUPeriod != 0 && (resources.CPUPeriod < 1000 || resources.CPUPeriod > 1000000) {
353353
return warnings, fmt.Errorf("CPU cfs period can not be less than 1ms (i.e. 1000) or larger than 1s (i.e. 1000000)")
354354
}
355355
if resources.CPUQuota > 0 && !sysInfo.CPUCfsQuota {
356356
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.")
358358
resources.CPUQuota = 0
359359
}
360360
if resources.CPUQuota > 0 && resources.CPUQuota < 1000 {
361361
return warnings, fmt.Errorf("CPU cfs quota can not be less than 1ms (i.e. 1000)")
362362
}
363363
if resources.CPUPercent > 0 {
364364
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)
366366
resources.CPUPercent = 0
367367
}
368368

369369
// cpuset subsystem checks and adjustments
370370
if (resources.CpusetCpus != "" || resources.CpusetMems != "") && !sysInfo.Cpuset {
371371
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.")
373373
resources.CpusetCpus = ""
374374
resources.CpusetMems = ""
375375
}
@@ -391,7 +391,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
391391
// blkio subsystem checks and adjustments
392392
if resources.BlkioWeight > 0 && !sysInfo.BlkioWeight {
393393
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.")
395395
resources.BlkioWeight = 0
396396
}
397397
if resources.BlkioWeight > 0 && (resources.BlkioWeight < 10 || resources.BlkioWeight > 1000) {
@@ -402,27 +402,27 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
402402
}
403403
if len(resources.BlkioWeightDevice) > 0 && !sysInfo.BlkioWeightDevice {
404404
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.")
406406
resources.BlkioWeightDevice = []*pblkiodev.WeightDevice{}
407407
}
408408
if len(resources.BlkioDeviceReadBps) > 0 && !sysInfo.BlkioReadBpsDevice {
409409
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.")
411411
resources.BlkioDeviceReadBps = []*pblkiodev.ThrottleDevice{}
412412
}
413413
if len(resources.BlkioDeviceWriteBps) > 0 && !sysInfo.BlkioWriteBpsDevice {
414414
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.")
416416
resources.BlkioDeviceWriteBps = []*pblkiodev.ThrottleDevice{}
417417
}
418418
if len(resources.BlkioDeviceReadIOps) > 0 && !sysInfo.BlkioReadIOpsDevice {
419419
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.")
421421
resources.BlkioDeviceReadIOps = []*pblkiodev.ThrottleDevice{}
422422
}
423423
if len(resources.BlkioDeviceWriteIOps) > 0 && !sysInfo.BlkioWriteIOpsDevice {
424424
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.")
426426
resources.BlkioDeviceWriteIOps = []*pblkiodev.ThrottleDevice{}
427427
}
428428

@@ -492,7 +492,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
492492
// ip-forwarding does not affect container with '--net=host' (or '--net=none')
493493
if sysInfo.IPv4ForwardingDisabled && !(hostConfig.NetworkMode.IsHost() || hostConfig.NetworkMode.IsNone()) {
494494
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")
496496
}
497497
// check for various conflicting options with user namespaces
498498
if daemon.configStore.RemappedRoot != "" && hostConfig.UsernsMode.IsPrivate() {
@@ -916,7 +916,7 @@ func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error)
916916
if username == "root" {
917917
// Cannot setup user namespaces with a 1-to-1 mapping; "--root=0:0" is a no-op
918918
// 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")
920920
return uidMaps, gidMaps, nil
921921
}
922922
logrus.Infof("User namespaces: ID ranges will be mapped to subuid/subgid ranges of: %s:%s", username, groupname)

daemon/daemon_windows.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,32 +111,32 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
111111

112112
if resources.BlkioWeight > 0 {
113113
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.")
115115
resources.BlkioWeight = 0
116116
}
117117
if len(resources.BlkioWeightDevice) > 0 {
118118
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.")
120120
resources.BlkioWeightDevice = []*pblkiodev.WeightDevice{}
121121
}
122122
if len(resources.BlkioDeviceReadBps) > 0 {
123123
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.")
125125
resources.BlkioDeviceReadBps = []*pblkiodev.ThrottleDevice{}
126126
}
127127
if len(resources.BlkioDeviceWriteBps) > 0 {
128128
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.")
130130
resources.BlkioDeviceWriteBps = []*pblkiodev.ThrottleDevice{}
131131
}
132132
if len(resources.BlkioDeviceReadIOps) > 0 {
133133
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.")
135135
resources.BlkioDeviceReadIOps = []*pblkiodev.ThrottleDevice{}
136136
}
137137
if len(resources.BlkioDeviceWriteIOps) > 0 {
138138
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.")
140140
resources.BlkioDeviceWriteIOps = []*pblkiodev.ThrottleDevice{}
141141
}
142142
return warnings, nil

daemon/graphdriver/devmapper/deviceset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
18151815

18161816
if devices.thinPoolDevice == "" {
18171817
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.")
18191819
}
18201820
}
18211821

daemon/graphdriver/windows/windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ func (d *Driver) GetCustomImageInfos() ([]CustomImageInfo, error) {
507507

508508
versionData := strings.Split(imageData.Version, ".")
509509
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)
511511
} else {
512512
// Include just major.minor.build, skip the fourth version field, which does not influence
513513
// OS compatibility.

daemon/kill.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (daemon *Daemon) killWithSignal(container *container.Container, sig int) er
8686
// if container or process not exists, ignore the error
8787
if strings.Contains(err.Error(), "container not found") ||
8888
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())
9090
} else {
9191
return err
9292
}

libcontainerd/remote_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ func (r *remote) getLastEventTimestamp() int64 {
226226
f, err := os.Open(r.eventTsPath)
227227
defer f.Close()
228228
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)
230230
return t.Unix()
231231
}
232232

233233
b := make([]byte, fi.Size())
234234
n, err := f.Read(b)
235235
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)
237237
return t.Unix()
238238
}
239239

pkg/sysinfo/sysinfo_linux.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func checkCgroupMem(cgMounts map[string]string, quiet bool) cgroupMemInfo {
7575
mountPoint, ok := cgMounts["memory"]
7676
if !ok {
7777
if !quiet {
78-
logrus.Warnf("Your kernel does not support cgroup memory limit")
78+
logrus.Warn("Your kernel does not support cgroup memory limit")
7979
}
8080
return cgroupMemInfo{}
8181
}
@@ -90,15 +90,15 @@ func checkCgroupMem(cgMounts map[string]string, quiet bool) cgroupMemInfo {
9090
}
9191
oomKillDisable := cgroupEnabled(mountPoint, "memory.oom_control")
9292
if !quiet && !oomKillDisable {
93-
logrus.Warnf("Your kernel does not support oom control.")
93+
logrus.Warn("Your kernel does not support oom control.")
9494
}
9595
memorySwappiness := cgroupEnabled(mountPoint, "memory.swappiness")
9696
if !quiet && !memorySwappiness {
97-
logrus.Warnf("Your kernel does not support memory swappiness.")
97+
logrus.Warn("Your kernel does not support memory swappiness.")
9898
}
9999
kernelMemory := cgroupEnabled(mountPoint, "memory.kmem.limit_in_bytes")
100100
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.")
102102
}
103103

104104
return cgroupMemInfo{
@@ -116,7 +116,7 @@ func checkCgroupCPU(cgMounts map[string]string, quiet bool) cgroupCPUInfo {
116116
mountPoint, ok := cgMounts["cpu"]
117117
if !ok {
118118
if !quiet {
119-
logrus.Warnf("Unable to find cpu cgroup in mounts")
119+
logrus.Warn("Unable to find cpu cgroup in mounts")
120120
}
121121
return cgroupCPUInfo{}
122122
}
@@ -147,7 +147,7 @@ func checkCgroupBlkioInfo(cgMounts map[string]string, quiet bool) cgroupBlkioInf
147147
mountPoint, ok := cgMounts["blkio"]
148148
if !ok {
149149
if !quiet {
150-
logrus.Warnf("Unable to find blkio cgroup in mounts")
150+
logrus.Warn("Unable to find blkio cgroup in mounts")
151151
}
152152
return cgroupBlkioInfo{}
153153
}
@@ -195,7 +195,7 @@ func checkCgroupCpusetInfo(cgMounts map[string]string, quiet bool) cgroupCpusetI
195195
mountPoint, ok := cgMounts["cpuset"]
196196
if !ok {
197197
if !quiet {
198-
logrus.Warnf("Unable to find cpuset cgroup in mounts")
198+
logrus.Warn("Unable to find cpuset cgroup in mounts")
199199
}
200200
return cgroupCpusetInfo{}
201201
}

0 commit comments

Comments
 (0)