Skip to content

Commit cd48a91

Browse files
authored
Revert "filesystem: fix mountTimeout not working issue (#2903)"
This reverts commit 9f1f791.
1 parent 1219247 commit cd48a91

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

collector/filesystem_linux.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,16 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta
123123

124124
buf := new(unix.Statfs_t)
125125
err := unix.Statfs(rootfsFilePath(labels.mountPoint), buf)
126+
stuckMountsMtx.Lock()
126127
close(success)
127128

129+
// If the mount has been marked as stuck, unmark it and log it's recovery.
130+
if _, ok := stuckMounts[labels.mountPoint]; ok {
131+
level.Debug(c.logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", labels.mountPoint)
132+
delete(stuckMounts, labels.mountPoint)
133+
}
134+
stuckMountsMtx.Unlock()
135+
128136
if err != nil {
129137
labels.deviceError = err.Error()
130138
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
155163
select {
156164
case <-success:
157165
// Success
158-
// If the mount has been marked as stuck, unmark it and log it's recovery.
159-
stuckMountsMtx.Lock()
160-
defer stuckMountsMtx.Unlock()
161-
if _, ok := stuckMounts[mountPoint]; ok {
162-
level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint)
163-
delete(stuckMounts, mountPoint)
164-
}
165166
case <-mountCheckTimer.C:
166167
// Timed out, mark mount as stuck
167168
stuckMountsMtx.Lock()
168-
defer stuckMountsMtx.Unlock()
169169
select {
170170
case <-success:
171171
// Success came in just after the timeout was reached, don't label the mount as stuck
172-
// If the mount has been marked as stuck, unmark it and log it's recovery.
173-
if _, ok := stuckMounts[mountPoint]; ok {
174-
level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint)
175-
delete(stuckMounts, mountPoint)
176-
}
177172
default:
178173
level.Debug(logger).Log("msg", "Mount point timed out, it is being labeled as stuck and will not be monitored", "mountpoint", mountPoint)
179174
stuckMounts[mountPoint] = struct{}{}
180175
}
176+
stuckMountsMtx.Unlock()
181177
}
182178
}
183179

0 commit comments

Comments
 (0)