thanos-io/thanos · error

write file

Error message

write file %v

What it means

Raised in Manager.Update after marshaling a strategy's rule groups to YAML: os.WriteFile fails to write the temporary rule file into workDir/<strategy>/<filename>. Typical causes are disk-full, permission denied on workDir, or a path collision; the affected strategy's rules are not updated.

Solutions

  1. Verify workDir exists and the process has write permissions
  2. Check free disk space on the volume hosting workDir
  3. Inspect the wrapped os.WriteFile error (path, errno) for the concrete cause
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/rules/manager.go:376 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/66beb3672a543d9f. Report an issue: GitHub.

Appendix: source

Thrown at pkg/rules/manager.go:376

		for _, rg := range rg.Groups {
			groupsByStrategy[*rg.PartialResponseStrategy] = append(groupsByStrategy[*rg.PartialResponseStrategy], rg)
		}
		for s, rg := range groupsByStrategy {
			b, err := yaml.Marshal(configGroups{Groups: rg})
			if err != nil {
				errs = append(errs, errors.Wrapf(err, "%s: failed to marshal rule groups", fn))
				continue
			}

			// Use full file name appending to work dir, so we can differentiate between different dirs and same filenames(!).
			// This will be also used as key for file group name.
			newFn := filepath.Join(m.workDir, s.String(), fn)
			if err := os.MkdirAll(filepath.Dir(newFn), os.ModePerm); err != nil {
				errs.Add(errors.Wrapf(err, "create %s", filepath.Dir(newFn)))
				continue
			}
			if err := os.WriteFile(newFn, b, os.ModePerm); err != nil {
				errs.Add(errors.Wrapf(err, "write file %v", newFn))
				continue
			}
			filesByStrategy[s] = append(filesByStrategy[s], newFn)
			ruleFiles[newFn] = fn
		}
	}

	m.mtx.Lock()
	for s, fs := range filesByStrategy {
		mgr, ok := m.mgrs[s]
		if !ok {
			errs.Add(errors.Errorf("no manager found for %v", s))
			continue
		}
		// We add external labels in `pkg/alert.Queue`.
		if err := mgr.Update(evalInterval, fs, m.extLset, m.externalURL, nil); err != nil {
			// TODO(bwplotka): Prometheus logs all error details. Fix it upstream to have consistent error handling.
			errs.Add(errors.Wrapf(err, "strategy %s, update rules", s))

View on GitHub (pinned to 35b8b99117)