thanos-io/thanos · error
rename file
Error message
rename file
What it means
Wraps os.Rename in Reloader.normalize: the atomically-staged .tmp file could not be renamed over the output file (cross-device link, target locked). The deferred cleanup removes the orphaned temp file and the reload attempt fails.
Solutions
- Ensure tmp and output files are on the same filesystem.
- Check output directory permissions.
- Investigate whether another process removed the path.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/reloader/reloader.go:394 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/b13c0aa0491cbdce.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/reloader/reloader.go:394
if err != nil {
return errors.Wrap(err, "read compressed config file")
}
}
b, err = r.expandEnv(b)
if err != nil {
return errors.Wrap(err, "expand environment variables")
}
tmpFile := outputFile + ".tmp"
defer func() {
_ = os.Remove(tmpFile)
}()
if err := os.WriteFile(tmpFile, b, 0644); err != nil {
return errors.Wrap(err, "write file")
}
if err := os.Rename(tmpFile, outputFile); err != nil {
return errors.Wrap(err, "rename file")
}
return nil
}
// apply triggers Prometheus reload if rules or config changed. If cfgOutputFile is set, we also
// expand env vars into config file before reloading.
// Reload is retried in retryInterval until watchInterval.
func (r *Reloader) apply(ctx context.Context) error {
var (
cfgHash []byte
watchedDirsHash []byte
)
if r.cfgFile != "" {
h := sha256.New()
if err := hashFile(h, r.cfgFile); err != nil {
return errors.Wrap(err, "hash file")
}View on GitHub (pinned to 35b8b99117)