{"record":{"id":"a66e61dd5f5781d6","repo":"kubernetes/kubernetes","slug":"empty-hostname-override-is-invalid","errorCode":null,"errorMessage":"empty hostname-override is invalid","messagePattern":"empty hostname-override is invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kube-proxy/app/options.go","lineNumber":328,"sourceCode":"\tif ent.Has(fsnotify.Write) || ent.Has(fsnotify.Rename) {\n\t\t// error out when ConfigFile is updated\n\t\to.errCh <- fmt.Errorf(\"content of the proxy server's configuration file was updated\")\n\t\treturn\n\t}\n\to.errCh <- nil\n}\n\nfunc (o *Options) errorHandler(err error) {\n\to.errCh <- err\n}\n\n// processHostnameOverrideFlag processes hostname-override flag\nfunc (o *Options) processHostnameOverrideFlag() error {\n\t// Check if hostname-override flag is set and use value since configFile always overrides\n\tif len(o.hostnameOverride) > 0 {\n\t\thostName := strings.TrimSpace(o.hostnameOverride)\n\t\tif len(hostName) == 0 {\n\t\t\treturn fmt.Errorf(\"empty hostname-override is invalid\")\n\t\t}\n\t\to.config.HostnameOverride = strings.ToLower(hostName)\n\t}\n\n\treturn nil\n}\n\n// processV1Alpha1Flags processes v1alpha1 flags which can't be directly mapped to internal config.\nfunc (o *Options) processV1Alpha1Flags(fs *pflag.FlagSet) {\n\tif fs.Changed(\"iptables-sync-period\") && o.config.Mode != kubeproxyconfig.ProxyModeIPVS {\n\t\to.config.SyncPeriod.Duration = o.iptablesSyncPeriod\n\t}\n\tif fs.Changed(\"iptables-min-sync-period\") && o.config.Mode != kubeproxyconfig.ProxyModeIPVS {\n\t\to.config.MinSyncPeriod.Duration = o.iptablesMinSyncPeriod\n\t}\n\tif fs.Changed(\"ipvs-sync-period\") && o.config.Mode == kubeproxyconfig.ProxyModeIPVS {\n\t\to.config.SyncPeriod.Duration = o.ipvsSyncPeriod\n\t}","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/cmd/kube-proxy/app/options.go#L310-L346","documentation":"processHostnameOverrideFlag trims the --hostname-override flag value; if the original was non-empty but reduces to empty after TrimSpace (i.e. only whitespace), it returns 'empty hostname-override is invalid' (options.go:328). An all-whitespace value is meaningless for a node name and is rejected explicitly.","triggerScenarios":"Launching kube-proxy with --hostname-override=\" \" or --hostname-override=\"\\t\", or a chart/helm template rendering a blank variable into that flag (e.g. {{ .Values.nodeName }} when unset yields spaces).","commonSituations":"Helm/templating emits spaces for an unset node name; an env var expanded to whitespace; a copy-paste from YAML where indentation introduced stray spaces.","solutions":["Set --hostname-override to a real, trimmed node name (lowercased automatically).","If you do not need an override, omit the flag entirely.","Fix the templating/env source so it does not emit whitespace.","Restart kube-proxy."],"exampleFix":"// before\n// --hostname-override=\"   \"\n// after\n// --hostname-override=node-1   (or omit the flag)","handlingStrategy":"validation","validationCode":"// Trim and reject whitespace-only hostname overrides before launch.\nfunc validateHostnameOverride(h string) error {\n    if len(h) == 0 {\n        return nil // flag omitted is valid\n    }\n    if len(strings.TrimSpace(h)) == 0 {\n        return fmt.Errorf(\"empty hostname-override is invalid\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Render --hostname-override only when the node-name variable is set in templates.","Omit the flag entirely if you rely on the node's actual hostname.","Lint rendered manifests for whitespace-only values."],"tags":["kubernetes","kube-proxy","hostname","flags","validation"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}