hashicorp/nomad · warning

failed to scan %s: %v

Error message

failed to scan %s: %v

What it means

searchFile opened the kernel metadata file but bufio.Scanner returned a non-nil error while reading it (I/O error, or a line exceeding the scanner's 64KB token limit). Like the other bridge detect errors, it is accumulated into multierror and merely disables the bridge fingerprint. Rare in practice; most failures are the open or not-found cases instead.

Source

Thrown at client/fingerprint/bridge_linux.go:124

}

func (f *BridgeFingerprint) searchFile(module, filename string, re *regexp.Regexp) error {
	file, err := os.Open(filename)
	if err != nil {
		return fmt.Errorf("failed to open %s: %v", filename, err)
	}
	defer func() {
		_ = file.Close()
	}()

	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		if re.MatchString(scanner.Text()) {
			return nil // found the module!
		}
	}
	if err := scanner.Err(); err != nil {
		return fmt.Errorf("failed to scan %s: %v", filename, err)
	}

	return fmt.Errorf("module %s not in %s", module, filename)
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Re-read the file manually ('cat /proc/modules', 'cat /lib/modules/$(uname -r)/modules.dep') to check for real I/O errors.
  2. If it's a scanner token-size issue, this is a Nomad-side limitation - load the module ('modprobe bridge') so detect succeeds earlier via /sys/module or /proc/modules, or file/patch the scanner buffer size.
  3. Check dmesg/storage health if the error recurs and indicates genuine read failures.
  4. If bridge mode is not used, the warning can be ignored.

Example fix

// before: scanner fails on a >64KB line
scanner := bufio.NewScanner(file)
scanner.Scan() // bufio.Scanner: token too long
// after (upstream-style fix)
scanner := bufio.NewScanner(file)
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) // allow 1MB lines
Defensive patterns

Strategy: fallback

Validate before calling

// host-side preflight (shell): ensure files are readable and lines are sane
// awk 'length($0) > 65536 { print FILENAME": long line "NR }' /lib/modules/$(uname -r)/modules.dep

Try / catch

if err := scanner.Err(); err != nil {
    // log and continue - detect() aggregates this and disables bridge mode gracefully
    f.logger.Warn("failed scanning kernel module file", "file", filename, "error", err)
    return fmt.Errorf("failed to scan %s: %v", filename, err)
}

Prevention

When it happens

Trigger: scanner.Err() non-nil during a scan of /proc/modules or /lib/modules/<ver>/modules.builtin|modules.dep - hardware/disk I/O errors reading procfs, or a single line longer than bufio.Scanner's default MaxScanTokenSize (64KB) in modules.dep.

Common situations: Extremely long modules.dep entries on kernels with heavy module dependency chains exceeding 64KB per line; transient I/O errors on degraded storage; unusual /proc configurations.

Related errors


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