{"record":{"id":"f2c0c51255f6c5d2","repo":"hashicorp/nomad","slug":"failed-to-load-cni-config-v","errorCode":null,"errorMessage":"failed to load CNI config: %v","messagePattern":"failed to load CNI config: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/networking_cni.go","lineNumber":69,"sourceCode":"\tdefaultCNIInterfacePrefix = \"eth\"\n)\n\ntype cniNetworkConfigurator struct {\n\tcni                     cni.CNI\n\tconfParser              *cniConfParser\n\tignorePortMappingHostIP bool\n\tnodeAttrs               map[string]string\n\tnodeMeta                map[string]string\n\trand                    *rand.Rand\n\tlogger                  log.Logger\n\tnsOpts                  *nsOpts\n\tnewIPTables             func(structs.NodeNetworkAF) (IPTablesCleanup, error)\n}\n\nfunc newCNINetworkConfigurator(logger log.Logger, cniPath, cniInterfacePrefix, cniConfDir, networkName string, ignorePortMappingHostIP bool, node *structs.Node) (*cniNetworkConfigurator, error) {\n\tparser, err := loadCNIConf(cniConfDir, networkName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load CNI config: %v\", err)\n\t}\n\n\treturn newCNINetworkConfiguratorWithConf(logger, cniPath, cniInterfacePrefix, ignorePortMappingHostIP, parser, node)\n}\n\nfunc newCNINetworkConfiguratorWithConf(logger log.Logger, cniPath, cniInterfacePrefix string, ignorePortMappingHostIP bool, parser *cniConfParser, node *structs.Node) (*cniNetworkConfigurator, error) {\n\tconf := &cniNetworkConfigurator{\n\t\tconfParser:              parser,\n\t\trand:                    rand.New(rand.NewSource(time.Now().Unix())),\n\t\tlogger:                  logger,\n\t\tignorePortMappingHostIP: ignorePortMappingHostIP,\n\t\tnodeAttrs:               node.Attributes,\n\t\tnodeMeta:                node.Meta,\n\t\tnsOpts:                  &nsOpts{},\n\t\tnewIPTables:             newIPTablesCleanup,\n\t}\n\tif cniPath == \"\" {\n\t\tif cniPath = os.Getenv(envCNIPath); cniPath == \"\" {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/networking_cni.go#L51-L87","documentation":"newCNINetworkConfigurator loads the CNI network configuration file for the given network name from cni_conf_dir via loadCNIConf. If no matching CNI conf JSON exists or it fails to parse, this error wraps the cause. The bridge/consul CNI setup cannot proceed without the plugin chain definition.","triggerScenarios":"loadCNIConf(cniConfDir, networkName) errors during client setup (called from newNetworkConfigurator): the conf dir has no file whose name matches networkName, the file is not valid JSON/CNI spec, or the dir path is wrong.","commonSituations":"client config 'bridge_network_name' (default 'nomad') with no corresponding /opt/cni/nomad or cni_conf_dir file; CNI configs deleted after host reboot (tmpfs); manually edited CNI JSON with syntax errors; wrong cni_config_dir path in client config.","solutions":["Create a CNI config file named after the network (e.g. nomad.conflist) in the configured cni_config_dir with a valid bridge/loopback plugin chain.","Ensure client config cni_config_dir points at the directory containing the CNI conf files.","Validate the CNI JSON (jq) and fix syntax/spec errors.","Re-run the node's provisioning that installs CNI configs (e.g. nomad init or consul-cni install scripts).","If not using bridge networking intentionally, disable client bridge config so this initializer isn't hit."],"exampleFix":"// before: /etc/cni/nomad.conf (invalid)\n{\"cniVersion\": \"0.4.0\"\n// after: nomad.conflist\n{\"cniVersion\":\"0.4.0\",\"name\":\"nomad\",\"plugins\":[{\"type\":\"bridge\",\"bridge\":\"nomad\"},{\"type\":\"loopback\"},{\"type\":\"firewall\"}]}","handlingStrategy":"validation","validationCode":"// before starting client with bridge networking\nconf=\"$CNI_CONF_DIR/${NETWORK_NAME}.conflist\"\n[ -f \"$conf\" ] && jq -e '.name, .cniVersion, .plugins' \"$conf\" >/dev/null || echo \"CNI conf missing/invalid: $conf\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision CNI conf files (nomad.conflist) via config management on every client.","Keep cni_config_dir on persistent storage, not tmpfs.","Validate CNI JSON with jq in node bootstrap scripts."],"tags":["nomad","cni","config-load","bridge-network"],"backgroundTag":"cni-config-missing-or-invalid","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"}