From 3a02ab1cf051d2f80f3b688c977961033300fda3 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 20 Feb 2024 10:31:08 +0100 Subject: [PATCH] Revert "filesystem: fix mountTimeout not working issue (#2903)" (#2932) This reverts commit 9f1f791ac2e1377781c4f8807a23d86d92ad6499. Signed-off-by: Ben Kochie --- collector/filesystem_linux.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 23e5359d..1d0c8493 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -123,8 +123,16 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta buf := new(unix.Statfs_t) err := unix.Statfs(rootfsFilePath(labels.mountPoint), buf) + stuckMountsMtx.Lock() close(success) + // If the mount has been marked as stuck, unmark it and log it's recovery. + if _, ok := stuckMounts[labels.mountPoint]; ok { + level.Debug(c.logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", labels.mountPoint) + delete(stuckMounts, labels.mountPoint) + } + stuckMountsMtx.Unlock() + if err != nil { labels.deviceError = err.Error() level.Debug(c.logger).Log("msg", "Error on statfs() system call", "rootfs", rootfsFilePath(labels.mountPoint), "err", err) @@ -155,29 +163,17 @@ func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logg select { case <-success: // Success - // If the mount has been marked as stuck, unmark it and log it's recovery. - stuckMountsMtx.Lock() - defer stuckMountsMtx.Unlock() - if _, ok := stuckMounts[mountPoint]; ok { - level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint) - delete(stuckMounts, mountPoint) - } case <-mountCheckTimer.C: // Timed out, mark mount as stuck stuckMountsMtx.Lock() - defer stuckMountsMtx.Unlock() select { case <-success: // Success came in just after the timeout was reached, don't label the mount as stuck - // If the mount has been marked as stuck, unmark it and log it's recovery. - if _, ok := stuckMounts[mountPoint]; ok { - level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint) - delete(stuckMounts, mountPoint) - } default: level.Debug(logger).Log("msg", "Mount point timed out, it is being labeled as stuck and will not be monitored", "mountpoint", mountPoint) stuckMounts[mountPoint] = struct{}{} } + stuckMountsMtx.Unlock() } }