thanos-io/thanos · error

hash file

Error message

hash file

What it means

Reloader.apply fails hashing the config file with hashFile for change detection — the file disappeared or became unreadable between watches — so the reload cycle aborts and is retried on the next interval.

Solutions

  1. Check that the config file path is stable and mounted.
  2. Inspect the wrapped OS error (ENOENT, EACCES).
  3. The Watch loop retries; fix the mount to stop the errors.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/reloader/reloader.go:411 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/505548716faec9ae. Report an issue: GitHub.

Appendix: source

Thrown at pkg/reloader/reloader.go:411

	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")
		}
		cfgHash = h.Sum(nil)
		if r.cfgOutputFile != "" {
			if err := r.normalize(r.cfgFile, r.cfgOutputFile); err != nil {
				return err
			}
		}
	}

	cfgDirsHash := make([][]byte, len(r.cfgDirs))
	cfgDirsChanged := len(r.lastCfgDirsHash) == 0 && len(r.cfgDirs) > 0
	for i, cfgDir := range r.cfgDirs {
		h := sha256.New()

		walkDir, err := filepath.EvalSymlinks(cfgDir.Dir)
		if err != nil {
			return errors.Wrap(err, "dir symlink eval")
		}

View on GitHub (pinned to 35b8b99117)