prometheus/discovery/file
Munem Hashmi 89b3ad45a8
discovery/file: restore atomic file writes in tests (#18259)
PR #17269 replaced atomic os.Rename-based file writes with
os.WriteFile to fix a Windows flake. However, os.WriteFile is not
atomic (it truncates then writes), and fsnotify can fire between
the truncate and write, causing the watcher to read an empty file
and replace valid targets with empty ones.

Restore atomicity by writing to a temporary file and renaming.
On Windows, retry the rename with a short backoff to handle
transient "Access is denied" errors when the file watcher or
readFile holds an open handle to the destination.

Fixes #18237

Signed-off-by: Munem Hashmi <munem.hashmi@gmail.com>
2026-03-11 08:12:56 +01:00
..
fixtures fixes yamllint errors 2021-06-12 12:47:47 +02:00
file.go chore: fix emptyStringTest issues from gocritic (#18226) 2026-03-04 08:24:50 +01:00
file_test.go discovery/file: restore atomic file writes in tests (#18259) 2026-03-11 08:12:56 +01:00
metrics.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00