{"record":{"id":"a9cf045b9f17fd7a","repo":"hashicorp/nomad","slug":"cni-not-initialized-w","errorCode":null,"errorMessage":"cni not initialized: %w","messagePattern":"cni not initialized: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/networking_cni.go","lineNumber":154,"sourceCode":"\t\t}\n\t}\n}\n\nvar supportsCNICheck = mustCNICheckConstraint()\n\nfunc mustCNICheckConstraint() version.Constraints {\n\tv, err := version.NewConstraint(\">= 1.3.0\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}\n\n// Setup calls the CNI plugins with the add action\nfunc (c *cniNetworkConfigurator) Setup(ctx context.Context, alloc *structs.Allocation, spec *drivers.NetworkIsolationSpec, created bool) (*structs.AllocNetworkStatus, error) {\n\n\tif err := c.ensureCNIInitialized(); err != nil {\n\t\treturn nil, fmt.Errorf(\"cni not initialized: %w\", err)\n\t}\n\tcniArgs := map[string]string{\n\t\t// CNI plugins are called one after the other with the same set of\n\t\t// arguments. Passing IgnoreUnknown=true signals to plugins that they\n\t\t// should ignore any arguments they don't understand\n\t\t\"IgnoreUnknown\": \"true\",\n\t}\n\n\ttg := alloc.Job.LookupTaskGroup(alloc.TaskGroup)\n\n\taddCustomCNIArgs(tg.Networks, cniArgs)\n\n\t// Add NOMAD_* after custom args so it cannot be overridden.\n\taddNomadWorkloadCNIArgs(c.logger, alloc, cniArgs)\n\n\tportMaps := getPortMapping(alloc, c.ignorePortMappingHostIP)\n\n\ttproxyArgs, err := c.setupTransparentProxyArgs(alloc, spec, portMaps)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/networking_cni.go#L136-L172","documentation":"cniNetworkConfigurator.Setup lazily initializes the CNI library handle (go-cni). ensureCNIInitialized returns an error if the CNI instance was never initialized (or init failed), and Setup wraps it with 'cni not initialized'. This guards against calling CNI add on an unusable configurator.","triggerScenarios":"c.ensureCNIInitialized() fails in Setup (and its anonymous retry caller): CNI init was skipped because no CNI config was loaded, the CNI plugin path doesn't contain required binaries, or lazy Init() errored (e.g. missing loopback/bridge plugin binaries).","commonSituations":"cni_plugin_dir missing the CNI binaries (bridge, loopback, firewall, portmap); CNI conf failed to load earlier leaving c *goCni nil; node configured for bridge networking but CNI plugin tarball never installed.","solutions":["Install the required CNI plugin binaries into the configured cni_plugin_dir (default /opt/cni/bin).","Ensure a valid CNI config exists (see 'failed to load CNI config') so lazy init can build the plugin chain.","Check the wrapped cause in the log to distinguish init-not-called vs init-failed.","Restart the client after fixing plugin path/config so the configurator re-initializes."],"exampleFix":"# before\n$ ls /opt/cni/bin\nls: cannot access '/opt/cni/bin': No such file or directory\n# after\n$ sudo wget -qO- https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz | sudo tar -C /opt/cni/bin -xz","handlingStrategy":"fallback","validationCode":"// verify plugins before client start\nfor p in bridge loopback firewall portmap; do\n  [ -x \"/opt/cni/bin/$p\" ] || echo \"missing CNI plugin: $p\"\ndone","typeGuard":null,"tryCatchPattern":"status, err := cfg.Setup(ctx, alloc, spec, created)\nif err != nil {\n  var sentinel *cniNotInitialized\n  if errors.As(err, &sentinel) {\n    // reinstall CNI plugins, then retry setup once\n  }\n}","preventionTips":["Install the CNI plugin tarball as part of node provisioning.","Include CNI binaries in the client AMI/image.","Monitor /opt/cni/bin contents in node health checks."],"tags":["nomad","cni","initialization","network-setup"],"backgroundTag":"cni-not-initialized","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"}