Skip to content

Commit 77ec788

Browse files
jpdsv-zhuravlev
authored andcommitted
os_release.go: Removed caching of modtime/filename of os-release file. (prometheus#2987)
Signed-off-by: Jonathan Davies <[email protected]> Signed-off-by: Vitaly Zhuravlev <[email protected]>
1 parent 7752ff9 commit 77ec788

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

collector/os_release.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ type osReleaseCollector struct {
6060
infoDesc *prometheus.Desc
6161
logger log.Logger
6262
os *osRelease
63-
osFilename string // file name of cached release information
64-
osMtime time.Time // mtime of cached release file
6563
osMutex sync.RWMutex
6664
osReleaseFilenames []string // all os-release file names to check
6765
version float64
@@ -134,28 +132,10 @@ func (c *osReleaseCollector) UpdateStruct(path string) error {
134132
}
135133
defer releaseFile.Close()
136134

137-
stat, err := releaseFile.Stat()
138-
if err != nil {
139-
return err
140-
}
141-
142-
t := stat.ModTime()
143-
c.osMutex.RLock()
144-
upToDate := path == c.osFilename && t == c.osMtime
145-
c.osMutex.RUnlock()
146-
if upToDate {
147-
// osReleaseCollector struct is already up-to-date.
148-
return nil
149-
}
150-
151135
// Acquire a lock to update the osReleaseCollector struct.
152136
c.osMutex.Lock()
153137
defer c.osMutex.Unlock()
154138

155-
level.Debug(c.logger).Log("msg", "file modification time has changed",
156-
"file", path, "old_value", c.osMtime, "new_value", t)
157-
c.osFilename = path
158-
c.osMtime = t
159139
// SystemVersion.plist is xml file with MacOs version info
160140
if strings.Contains(releaseFile.Name(), "SystemVersion.plist") {
161141
c.os, err = getMacosProductVersion(releaseFile.Name())

0 commit comments

Comments
 (0)