Skip to content

Commit fb67db7

Browse files
committed
Conditionally gathering FS usage metrics.
1 parent b64cee0 commit fb67db7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

container/docker/factory.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,25 @@ func Register(factory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics
347347
var (
348348
thinPoolWatcher *devicemapper.ThinPoolWatcher
349349
thinPoolName string
350+
zfsWatcher *zfs.ZfsWatcher
350351
)
351-
if storageDriver(dockerInfo.Driver) == devicemapperStorageDriver {
352-
thinPoolWatcher, err = startThinPoolWatcher(dockerInfo)
353-
if err != nil {
354-
klog.Errorf("devicemapper filesystem stats will not be reported: %v", err)
355-
}
352+
if includedMetrics.Has(container.DiskUsageMetrics) {
353+
if storageDriver(dockerInfo.Driver) == devicemapperStorageDriver {
354+
thinPoolWatcher, err = startThinPoolWatcher(dockerInfo)
355+
if err != nil {
356+
klog.Errorf("devicemapper filesystem stats will not be reported: %v", err)
357+
}
356358

357-
// Safe to ignore error - driver status should always be populated.
358-
status, _ := StatusFromDockerInfo(*dockerInfo)
359-
thinPoolName = status.DriverStatus[dockerutil.DriverStatusPoolName]
360-
}
359+
// Safe to ignore error - driver status should always be populated.
360+
status, _ := StatusFromDockerInfo(*dockerInfo)
361+
thinPoolName = status.DriverStatus[dockerutil.DriverStatusPoolName]
362+
}
361363

362-
var zfsWatcher *zfs.ZfsWatcher
363-
if storageDriver(dockerInfo.Driver) == zfsStorageDriver {
364-
zfsWatcher, err = startZfsWatcher(dockerInfo)
365-
if err != nil {
366-
klog.Errorf("zfs filesystem stats will not be reported: %v", err)
364+
if storageDriver(dockerInfo.Driver) == zfsStorageDriver {
365+
zfsWatcher, err = startZfsWatcher(dockerInfo)
366+
if err != nil {
367+
klog.Errorf("zfs filesystem stats will not be reported: %v", err)
368+
}
367369
}
368370
}
369371

0 commit comments

Comments
 (0)