{"record":{"id":"702d99f31fb0cea0","repo":"kubernetes/kops","slug":"host-is-required","errorCode":null,"errorMessage":"host is required","messagePattern":"host is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":100,"sourceCode":"\nfunc (o *ToolboxEnrollOptions) InitDefaults() {\n\to.SSHUser = \"root\"\n\to.SSHPort = 22\n}\n\nfunc RunToolboxEnroll(ctx context.Context, f commandutils.Factory, out io.Writer, options *ToolboxEnrollOptions) error {\n\tif !featureflag.Metal.Enabled() {\n\t\treturn fmt.Errorf(\"bare-metal support requires the Metal feature flag to be enabled\")\n\t}\n\tif options.ClusterName == \"\" {\n\t\treturn fmt.Errorf(\"cluster is required\")\n\t}\n\tif options.InstanceGroup == \"\" {\n\t\treturn fmt.Errorf(\"instance-group is required\")\n\t}\n\tif options.Host == \"\" {\n\t\t// Technically we could build the host resource without the PKI, but this isn't the case we are targeting right now.\n\t\treturn fmt.Errorf(\"host is required\")\n\t}\n\n\t// Resolve KOPS_BASE_URL early so that kops.Version is overridden\n\t// before the version downgrade check in ApplyClusterCmd.Run.\n\tif _, err := wellknownassets.BaseURL(); err != nil {\n\t\treturn err\n\t}\n\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconfigBuilder := &ConfigBuilder{\n\t\tClientset:         clientset,\n\t\tClusterName:       options.ClusterName,\n\t\tInstanceGroupName: options.InstanceGroup,\n\t}","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L82-L118","documentation":"The enroll command needs the address (IP or hostname) of the bare-metal machine to SSH into and build the Host resource; without it no enrollment work is possible. RunToolboxEnroll validates `options.Host` up front and returns this error when it is empty.","triggerScenarios":"Running `kops toolbox enroll` with --cluster and --instance-group set but no `--host` (or an empty interpolated variable).","commonSituations":"Loop scripts where the host variable failed to expand; enrolling from a metadata/CSV where the IP column was blank; misremembering the flag name.","solutions":["Pass `--host <ip-or-hostname>` reachable via SSH as root (default SSH user/port)","Fix the loop/variable so the host value is non-empty before invoking kops","Confirm network reachability: `ssh root@<host>` should work with your key"],"exampleFix":"// before\nHOSTS=\"\"; for h in $HOSTS; do kops toolbox enroll --cluster c --instance-group metal --host $h; done\n// after\nHOSTS=\"10.0.0.5 10.0.0.6\"; for h in $HOSTS; do kops toolbox enroll --cluster c --instance-group metal --host $h; done","handlingStrategy":"validation","validationCode":"for h in $HOSTS; do\n  [ -n \"$h\" ] || { echo \"empty host in list\"; exit 1; }\n  ssh -o BatchMode=yes -o ConnectTimeout=5 \"root@$h\" true || { echo \"host $h unreachable\"; exit 1; }\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate host lists are non-empty before loops","Pre-check SSH reachability with a quick BatchMode probe","Quote variables in scripts so empty values are caught early"],"tags":["cli","validation","ssh","missing-argument"],"backgroundTag":"missing-required-flag","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}