hashicorp/nomad · error

failed to determine disk space for %s: %v

Error message

failed to determine disk space for %s: %v

What it means

The storage fingerprinter could not determine total disk space for the storage directory. It calls f.diskInfo(storageDir) (which shells out to `df` on Unix) and wraps any diskInfo failure with the directory path in this message.

Source

Thrown at client/fingerprint/storage.go:44

	return fp
}

func (f *StorageFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
	cfg := req.Config

	// Guard against unset AllocDir
	storageDir := cfg.AllocDir
	if storageDir == "" {
		var err error
		storageDir, err = os.Getwd()
		if err != nil {
			return fmt.Errorf("unable to get CWD from filesystem: %s", err)
		}
	}

	volume, total, err := f.diskInfo(storageDir)
	if err != nil {
		return fmt.Errorf("failed to determine disk space for %s: %v", storageDir, err)
	}

	if cfg.DiskTotalMB > 0 {
		total = uint64(cfg.DiskTotalMB) * bytesPerMegabyte
	}

	resp.AddAttribute("unique.storage.volume", volume)
	resp.AddAttribute("unique.storage.bytestotal", strconv.FormatUint(total, 10))

	// set the disk size for the response
	resp.NodeResources = &structs.NodeResources{
		Disk: structs.NodeDiskResources{
			DiskMB: int64(total / bytesPerMegabyte),
		},
	}
	resp.Detected = true

	return nil

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check the wrapped %v error to see which underlying diskInfo step failed.
  2. Ensure the storage/alloc directory exists and is accessible.
  3. Verify `df` is installed and works manually: df -k <storageDir>.
  4. Set DiskTotalMB in the fingerprint config to override auto-detection.

Example fix

// before
# alloc_dir = "/nonexistent/path"
// after
client {
  alloc_dir = "/opt/nomad/data/alloc"
}
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(storageDir)
if err != nil || !info.IsDir() {
	return fmt.Errorf("storage dir %s must exist before fingerprinting", storageDir)
}

Try / catch

if err := fp.Fingerprint(req); err != nil {
	if strings.Contains(err.Error(), "failed to determine disk space for") {
		log.Printf("disk fingerprint skipped: %v", err)
		return nil
	}
	return err
}

Prevention

When it happens

Trigger: Fingerprint on the storage fingerprinter where diskInfo fails: the path cannot be made absolute, the `df` command fails, or `df` output cannot be parsed (see storage_unix.go errors 905-909).

Common situations: AllocDir points at a nonexistent path; `df` missing from PATH or non-executable; exotic filesystems whose df output breaks parsing; paths with unusual characters.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/4df8a99431ca05ca. Report an issue: GitHub.