Skip to content

Commit

Permalink
filesystem: fix mountTimeout not working issue
Browse files Browse the repository at this point in the history
Signed-off-by: 董薇 <dongw1@chinatelecom.cn>
  • Loading branch information
DongWei-4 committed Jan 22, 2024
1 parent 7317b91 commit 4fce1d3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions collector/filesystem_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta

buf := new(unix.Statfs_t)
err := unix.Statfs(rootfsFilePath(labels.mountPoint), buf)
stuckMountsMtx.Lock()
close(success)

if err != nil {
Expand Down Expand Up @@ -155,11 +154,12 @@ func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logg
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)
}
stuckMountsMtx.Unlock()
case <-mountCheckTimer.C:
// Timed out, mark mount as stuck
stuckMountsMtx.Lock()
Expand All @@ -171,7 +171,6 @@ func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logg
level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint)
delete(stuckMounts, mountPoint)
}
stuckMountsMtx.Unlock()
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{}{}
Expand Down

0 comments on commit 4fce1d3

Please sign in to comment.