{"record":{"id":"fafb08636c3df2af","repo":"containerd/containerd","slug":"not-implemented-on-unix","errorCode":null,"errorMessage":"not implemented on unix","messagePattern":"not implemented on unix","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/netns/netns_other.go","lineNumber":25,"sourceCode":"   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n\npackage netns\n\nimport (\n\t\"errors\"\n)\n\nvar errNotImplementedOnUnix = errors.New(\"not implemented on unix\")\n\n// NetNS holds network namespace.\ntype NetNS struct {\n\tpath string\n}\n\n// NewNetNS creates a network namespace.\nfunc NewNetNS(baseDir string) (*NetNS, error) {\n\treturn nil, errNotImplementedOnUnix\n}\n\n// NewNetNSFromPID returns the netns from pid or a new netns if pid is 0.\nfunc NewNetNSFromPID(baseDir string, pid uint32) (*NetNS, error) {\n\treturn nil, errNotImplementedOnUnix\n}\n\n// LoadNetNS loads existing network namespace.\nfunc LoadNetNS(path string) *NetNS {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/pkg/netns/netns_other.go#L7-L43","documentation":"errNotImplementedOnUnix is the stub error returned by every NetNS constructor/operation in the non-Linux (netns_other.go) build of pkg/netns, because network namespaces are a Linux-only kernel feature. Any attempt to create, remove, or query a NetNS on a platform compiled against this file fails immediately with this error.","triggerScenarios":"Calling NewNetNS, NewNetNSFromPID, Remove, or Closed on a build targeting a non-Linux OS (e.g. darwin, freebsd) where netns_other.go is compiled in.","commonSituations":"Running containerd or a containerd-based tool on macOS for local development; unit tests built with GOOS=darwin or GOOS=windows; sandbox/Pods (e.g. Kubernetes CRI sandbox creation) attempted on unsupported hosts.","solutions":["Run the workload on Linux, where the real netns_linux.go implementation is compiled","On macOS, use a Linux VM or container (Docker for Mac, Lima, colima) for namespace-dependent features","Guard code with runtime.GOOS == \"linux\" and skip/replace NetNS-dependent paths elsewhere","If a stub is needed for tests, build against this stub deliberately and never call these functions"],"exampleFix":"// before\nns, err := netns.NewNetNS() // fails on darwin\n\n// after\nif runtime.GOOS != \"linux\" {\n    return errors.New(\"network namespaces require Linux\")\n}\nns, err := netns.NewNetNS()","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"linux\" {\n    // NetNS APIs are stubbed on non-Linux builds\n    return errors.New(\"network namespaces require Linux\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Branch on runtime.GOOS before any NetNS call","Use build tags to compile Linux-only code paths only on Linux","Develop on macOS inside a Linux VM for namespace features","Document Linux-only requirements for tools using pkg/netns"],"tags":["platform","linux","network-namespace","unimplemented"],"backgroundTag":"platform-not-supported","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}