{"record":{"id":"3dc767986c161017","repo":"kubernetes/kubernetes","slug":"usage-of-node-cidr-mask-size-ipv4-and-node-cid-3dc767","errorCode":null,"errorMessage":"usage of --node-cidr-mask-size-ipv4 and --node-cidr-mask-size-ipv6 is not allowed if --node-cidr-mask-size is set. For dual-stack clusters please unset it and use IPFamily specific flags","messagePattern":"usage of --node-cidr-mask-size-ipv4 and --node-cidr-mask-size-ipv6 is not allowed if --node-cidr-mask-size is set\\. For dual-stack clusters please unset it and use IPFamily specific flags","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kube-controller-manager/app/core.go","lineNumber":944,"sourceCode":"\t\tif cfg.NodeCIDRMaskSizeIPv4 != 0 {\n\t\t\tipv4Mask = int(cfg.NodeCIDRMaskSizeIPv4)\n\t\t}\n\t\tif cfg.NodeCIDRMaskSizeIPv6 != 0 {\n\t\t\tipv6Mask = int(cfg.NodeCIDRMaskSizeIPv6)\n\t\t}\n\t\treturn sortedSizes(ipv4Mask, ipv6Mask), nil\n\t}\n\n\tmaskConfigured := cfg.NodeCIDRMaskSize != 0\n\tmaskV4Configured := cfg.NodeCIDRMaskSizeIPv4 != 0\n\tmaskV6Configured := cfg.NodeCIDRMaskSizeIPv6 != 0\n\tisSingleStackIPv6 := netutils.IsIPv6CIDR(clusterCIDRs[0])\n\n\t// original flag is set\n\tif maskConfigured {\n\t\t// original mask flag is still the main reference.\n\t\tif maskV4Configured || maskV6Configured {\n\t\t\treturn nil, errors.New(\"usage of --node-cidr-mask-size-ipv4 and --node-cidr-mask-size-ipv6 is not allowed if --node-cidr-mask-size is set. For dual-stack clusters please unset it and use IPFamily specific flags\")\n\t\t}\n\n\t\tmask := int(cfg.NodeCIDRMaskSize)\n\t\treturn sortedSizes(mask, mask), nil\n\t}\n\n\tif maskV4Configured {\n\t\tif isSingleStackIPv6 {\n\t\t\treturn nil, errors.New(\"usage of --node-cidr-mask-size-ipv4 is not allowed for a single-stack IPv6 cluster\")\n\t\t}\n\n\t\tipv4Mask = int(cfg.NodeCIDRMaskSizeIPv4)\n\t}\n\n\t// !maskV4Configured && !maskConfigured && maskV6Configured\n\tif maskV6Configured {\n\t\tif !isSingleStackIPv6 {\n\t\t\treturn nil, errors.New(\"usage of --node-cidr-mask-size-ipv6 is not allowed for a single-stack IPv4 cluster\")","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/cmd/kube-controller-manager/app/core.go#L926-L962","documentation":"In single-stack mode the legacy --node-cidr-mask-size is authoritative and is mutually exclusive with the family-specific --node-cidr-mask-size-ipv4 / -ipv6 flags. KCM's setNodeCIDRMaskSizes rejects setting any family flag alongside the legacy one to avoid contradictory config.","triggerScenarios":"Single cluster CIDR, cfg.NodeCIDRMaskSize != 0 AND (NodeCIDRMaskSizeIPv4 != 0 OR NodeCIDRMaskSizeIPv6 != 0). core.go:941-944.","commonSituations":"Flag migration leaving both old and new set; chart defaults that populate all mask flags; merging configs from different sources.","solutions":["Keep only --node-cidr-mask-size (single-stack), or unset it and keep the family-specific flags.","Lint the final flag set to ensure the legacy and family flags are not both present."],"exampleFix":"# before\n--node-cidr-mask-size=24 --node-cidr-mask-size-ipv6=64\n# after\n--node-cidr-mask-size=24","handlingStrategy":"validation","validationCode":"maskConfigured := cfg.NodeCIDRMaskSize != 0\nif maskConfigured && (cfg.NodeCIDRMaskSizeIPv4 != 0 || cfg.NodeCIDRMaskSizeIPv6 != 0) {\n    return errors.New(\"--node-cidr-mask-size is mutually exclusive with v4/v6 mask flags\")\n}","typeGuard":"func mutuallyExclusiveMasksSet(cfg nodeipamconfig.NodeIPAMControllerConfiguration) bool {\n    return cfg.NodeCIDRMaskSize != 0 && (cfg.NodeCIDRMaskSizeIPv4 != 0 || cfg.NodeCIDRMaskSizeIPv6 != 0)\n}","tryCatchPattern":null,"preventionTips":["Finish migrating off the legacy mask flag before introducing family flags.","Lint the union of all mask flags in rendered manifests."],"tags":["kubernetes","kube-controller-manager","cidr","networking","configuration"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}