mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
devmapper: Fix libdm logging
There are issues with libdm logging. Right now if docker daemon is run in debug mode, logging by libdm is too verbose. And if a device can't be removed, thousands of messages fill the console and one can not see what's going on. This patch removes devicemapper.LogInitVerbose() call as that call will only work if docker was not registering its own log handler with libdm. For some reason docker registers one with libdm and libdm hands over all the messages to docker (including debug ones). And now it is up to devmapper backend to figure out which ones should go to console and which ones should not. So by default log only fatal messages from libdm. One can easily modify the code to change it for debugging purposes. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
104b20a133
commit
e07d3cd9ac
1 changed files with 17 additions and 10 deletions
|
@ -33,6 +33,10 @@ var (
|
|||
DefaultThinpBlockSize uint32 = 128 // 64K = 128 512b sectors
|
||||
MaxDeviceId int = 0xffffff // 24 bit, pool limit
|
||||
DeviceIdMapSz int = (MaxDeviceId + 1) / 8
|
||||
// We retry device removal so many a times that even error messages
|
||||
// will fill up console during normal operation. So only log Fatal
|
||||
// messages by default.
|
||||
DMLogLevel int = devicemapper.LogLevelFatal
|
||||
)
|
||||
|
||||
const deviceSetMetaFile string = "deviceset-metadata"
|
||||
|
@ -723,14 +727,22 @@ func setCloseOnExec(name string) {
|
|||
}
|
||||
|
||||
func (devices *DeviceSet) DMLog(level int, file string, line int, dmError int, message string) {
|
||||
if level >= devicemapper.LogLevelDebug {
|
||||
// (vbatts) libdm debug is very verbose. If you're debugging libdm, you can
|
||||
// comment out this check yourself
|
||||
level = devicemapper.LogLevelInfo
|
||||
// By default libdm sends us all the messages including debug ones.
|
||||
// We need to filter out messages here and figure out which one
|
||||
// should be printed.
|
||||
if level > DMLogLevel {
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME(vbatts) push this back into ./pkg/devicemapper/
|
||||
if level <= devicemapper.LogLevelErr {
|
||||
logrus.Errorf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message)
|
||||
} else if level <= devicemapper.LogLevelInfo {
|
||||
logrus.Infof("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message)
|
||||
} else {
|
||||
// FIXME(vbatts) push this back into ./pkg/devicemapper/
|
||||
logrus.Debugf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message)
|
||||
}
|
||||
}
|
||||
|
||||
func major(device uint64) uint64 {
|
||||
|
@ -947,11 +959,6 @@ func (devices *DeviceSet) closeTransaction() error {
|
|||
}
|
||||
|
||||
func (devices *DeviceSet) initDevmapper(doInit bool) error {
|
||||
if os.Getenv("DEBUG") != "" {
|
||||
devicemapper.LogInitVerbose(devicemapper.LogLevelDebug)
|
||||
} else {
|
||||
devicemapper.LogInitVerbose(devicemapper.LogLevelWarn)
|
||||
}
|
||||
// give ourselves to libdm as a log handler
|
||||
devicemapper.LogInit(devices)
|
||||
|
||||
|
|
Loading…
Reference in a new issue