{"record":{"id":"9821c486a60147fd","repo":"hashicorp/nomad","slug":"no-cni-network-config-found","errorCode":null,"errorMessage":"no CNI network config found","messagePattern":"no CNI network config found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/networking_cni.go","lineNumber":545,"sourceCode":"\treturn netStatus, nil\n}\n\n// cniConfParser parses different config formats as appropriate\ntype cniConfParser struct {\n\tlistBytes []byte\n\tconfBytes []byte\n}\n\n// getOpt produces a cni.Opt to load with cni.CNI.Load()\nfunc (c *cniConfParser) getOpt() (cni.Opt, error) {\n\tif len(c.listBytes) > 0 {\n\t\treturn cni.WithConfListBytes(c.listBytes), nil\n\t}\n\tif len(c.confBytes) > 0 {\n\t\treturn cni.WithConf(c.confBytes), nil\n\t}\n\t// theoretically should never be reached\n\treturn nil, errors.New(\"no CNI network config found\")\n}\n\n// loadCNIConf looks in confDir for a CNI config with the specified name\nfunc loadCNIConf(confDir, name string) (*cniConfParser, error) {\n\tfiles, err := cnilibrary.ConfFiles(confDir, []string{\".conf\", \".conflist\", \".json\"})\n\tswitch {\n\tcase err != nil:\n\t\treturn nil, fmt.Errorf(\"failed to detect CNI config file: %v\", err)\n\tcase len(files) == 0:\n\t\treturn nil, fmt.Errorf(\"no CNI network config found in %s\", confDir)\n\t}\n\n\t// files contains the network config files associated with cni network.\n\t// Use lexicographical way as a defined order for network config files.\n\tsort.Strings(files)\n\tfor _, confFile := range files {\n\t\tif strings.HasSuffix(confFile, \".conflist\") {\n\t\t\tconfList, err := cnilibrary.ConfListFromFile(confFile)","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/networking_cni.go#L527-L563","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","Confirm file extension is one of .conf, .conflist, .json and the JSON parses; rename or fix the file.","Restart the Nomad client after adding configs so CNI init reloads them."],"exampleFix":"// before: configs only under /etc/cni/net.d, nomad uses its own dir\n// after:\ncp /etc/cni/net.d/10-bridge.conflist /opt/cni/config/10-bridge.conflist\n// and in nomad.hcl:\n// client { cni_config_dir = \"/opt/cni/config\" }","handlingStrategy":"validation","validationCode":"# run before starting the nomad client / submitting CNI-mode jobs\nconf_dir=/opt/cni/config; net_name=bridge\nls \"$conf_dir\"/*.{conf,conflist,json} 2>/dev/null || echo \"ERROR: no CNI configs in $conf_dir\"\ngrep -q '\"name\"' \"$conf_dir\"/*.conflist 2>/dev/null || echo \"ERROR: no named conflists\"\nnomad node status -verbose | grep cni","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision cni_config_dir with the needed .conflist files via config management before the client joins.","Keep the conflist 'name' field identical to the network name used in job network.mode CNI references.","After changing configs, restart the nomad client to re-run CNI init.","Smoke-test CNI mode with a trivial job using network { mode = \"cni/<name>\" } on each node."],"tags":["cni","network","nomad","configuration"],"backgroundTag":"cni-config-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}