hashicorp/nomad · error

no CNI network config found

Error message

no CNI network config found

What it means

Returned by getOpt in networking_cni.go when neither a conflist (listBytes), a plain conf (confBytes), nor (per the surrounding code) a knotable path was resolved for the named CNI network. The function's comment says it 'theoretically should never be reached' — it is a defensive guard reached when loadCNIConf found no usable CNI config file for the requested network name in cni_config_dir.

Source

Thrown at client/allocrunner/networking_cni.go:545

	return netStatus, nil
}

// cniConfParser parses different config formats as appropriate
type cniConfParser struct {
	listBytes []byte
	confBytes []byte
}

// getOpt produces a cni.Opt to load with cni.CNI.Load()
func (c *cniConfParser) getOpt() (cni.Opt, error) {
	if len(c.listBytes) > 0 {
		return cni.WithConfListBytes(c.listBytes), nil
	}
	if len(c.confBytes) > 0 {
		return cni.WithConf(c.confBytes), nil
	}
	// theoretically should never be reached
	return nil, errors.New("no CNI network config found")
}

// loadCNIConf looks in confDir for a CNI config with the specified name
func loadCNIConf(confDir, name string) (*cniConfParser, error) {
	files, err := cnilibrary.ConfFiles(confDir, []string{".conf", ".conflist", ".json"})
	switch {
	case err != nil:
		return nil, fmt.Errorf("failed to detect CNI config file: %v", err)
	case len(files) == 0:
		return nil, fmt.Errorf("no CNI network config found in %s", confDir)
	}

	// files contains the network config files associated with cni network.
	// Use lexicographical way as a defined order for network config files.
	sort.Strings(files)
	for _, confFile := range files {
		if strings.HasSuffix(confFile, ".conflist") {
			confList, err := cnilibrary.ConfListFromFile(confFile)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Install the CNI config for the referenced network name into client.cni_config_dir (e.g. 10-bridge.conflist) and make sure its 'name' field matches the mode's network name.
  2. Verify client.cni_config_dir in the Nomad agent config points at the directory actually containing the files; fix the path or copy configs there.
  3. Confirm file extension is one of .conf, .conflist, .json and the JSON parses; rename or fix the file.
  4. Restart the Nomad client after adding configs so CNI init reloads them.

Example fix

// before: configs only under /etc/cni/net.d, nomad uses its own dir
// after:
cp /etc/cni/net.d/10-bridge.conflist /opt/cni/config/10-bridge.conflist
// and in nomad.hcl:
// client { cni_config_dir = "/opt/cni/config" }
Defensive patterns

Strategy: validation

Validate before calling

# run before starting the nomad client / submitting CNI-mode jobs
conf_dir=/opt/cni/config; net_name=bridge
ls "$conf_dir"/*.{conf,conflist,json} 2>/dev/null || echo "ERROR: no CNI configs in $conf_dir"
grep -q '"name"' "$conf_dir"/*.conflist 2>/dev/null || echo "ERROR: no named conflists"
nomad node status -verbose | grep cni

Prevention

When it happens

Trigger: ensureCNIInitialized builds CNI opts for the alloc's network mode; getOpt finds c.listBytes == nil and c.confBytes == nil after loadCNIConf scanned c.confDir — i.e. no .conf/.conflist/.json file matched the CNI network name in the configured cni_config_dir.

Common situations: client { cni_config_dir } points to a directory without the config for that network name; config file extension unsupported or name mismatch (file must match the network name in mode CNI settings); configs installed in /etc/cni/net.d (k8s default) but Nomad configured a different dir; file is a .list or has wrong JSON schema so the parser skipped it.

Related errors


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