hashicorp/nomad · warning

failed to open %s: %v

Error message

failed to open %s: %v

What it means

searchFile opens a kernel metadata file (e.g. /proc/modules, /lib/modules/<ver>/modules.builtin or modules.dep) and scans it for the bridge module. This error means os.Open failed on that file. Combined with other detect() failures it just disables the bridge fingerprint; it never fails the client. It indicates the kernel metadata file itself is unreadable or absent.

Source

Thrown at client/fingerprint/bridge_linux.go:111

	} else {
		return nil
	}

	return errs
}

func (f *BridgeFingerprint) findDir(dirname string) error {
	if _, err := os.Stat(dirname); err != nil {
		return fmt.Errorf("failed to find %s: %v", dirname, err)
	} else {
		return nil
	}
}

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. Install kernel modules metadata for the running kernel (e.g. 'apt install linux-modules-$(uname -r)' or matching package) or mount /lib/modules:ro into the container.
  2. Load the bridge module directly ('modprobe bridge') so detect succeeds at the /sys/module or /proc/modules stage.
  3. If in a container, bind-mount /proc and /lib/modules from the host.
  4. If bridge mode is unused, this can be safely ignored - the node just won't advertise bridge networking.

Example fix

// before (docker run without kernel modules)
docker run nomad ...
// after
docker run -v /lib/modules:/lib/modules:ro -v /proc:/host/proc nomad ...
// or on the host: sudo apt-get install linux-modules-$(uname -r)
Defensive patterns

Strategy: fallback

Validate before calling

// host-side preflight (shell)
// test -r /proc/modules || echo 'no /proc/modules'
// test -d /lib/modules/$(uname -r) || echo 'install kernel modules metadata for running kernel'

Try / catch

if err := f.searchFile(module, path, re); err != nil {
    // treat unreadable kernel metadata as 'not detected', not fatal
    errs = multierror.Append(errs, err)
    // continue probing other locations (this is what detect() already does)
}

Prevention

When it happens

Trigger: detect('bridge') falls through to searchFile on /proc/modules or /lib/modules/<KernelVersion>/modules.builtin|modules.dep and os.Open returns an error - file missing (no /lib/modules for the running kernel version, stripped host image) or unreadable due to permissions/namespace restrictions.

Common situations: Minimal or distroless host images without /lib/modules installed; running Nomad in a container without /proc or /lib/modules mounted; kernel upgraded without matching linux-modules package so <KernelVersion> directory is absent.

Related errors


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