{"record":{"id":"a53b0e5699cf0807","repo":"kubernetes/kops","slug":"cannot-create-cluster-validator-v-a53b0e","errorCode":null,"errorMessage":"cannot create cluster validator: %v","messagePattern":"cannot create cluster validator: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/rolling-update_cluster.go","lineNumber":465,"sourceCode":"\t\tfmt.Printf(\"\\nNo rolling-update required.\\n\")\n\t\treturn nil\n\t}\n\n\tif !options.Yes {\n\t\tfmt.Printf(\"\\nMust specify --yes to rolling-update.\\n\")\n\t\treturn nil\n\t}\n\n\tvar clusterValidator validation.ClusterValidator\n\tif !options.CloudOnly {\n\t\trestConfig, err := f.RESTConfig(ctx, cluster, options.CreateKubecfgOptions)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting rest config: %w\", err)\n\t\t}\n\n\t\tclusterValidator, err = validation.NewClusterValidator(cluster, cloud, list, nil, nil, 0, restConfig, k8sClient)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot create cluster validator: %v\", err)\n\t\t}\n\t}\n\td.ClusterValidator = clusterValidator\n\n\treturn d.RollingUpdate(ctx, groups, list)\n}\n\nfunc completeInstanceGroup(f commandutils.Factory, selectedInstanceGroups *[]string, selectedInstanceGroupRoles *[]string) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\treturn func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t\tctx := cmd.Context()\n\n\t\tcommandutils.ConfigureKlogForCompletion()\n\n\t\tcluster, clientSet, completions, directive := GetClusterForCompletion(ctx, f, args)\n\t\tif cluster == nil {\n\t\t\treturn completions, directive\n\t\t}\n","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/rolling-update_cluster.go#L447-L483","documentation":"With a restConfig in hand, RunRollingUpdateCluster calls validation.NewClusterValidator(cluster, cloud, list, nil, nil, 0, restConfig, k8sClient) to build the validator used to confirm rolling-update progress via the API. If constructing it fails, the error is wrapped as \"cannot create cluster validator: %v\". This indicates an internal inconsistency — e.g. client construction inside the validator failed despite the restConfig being valid.","triggerScenarios":"validation.NewClusterValidator returns a non-nil error when passed the cluster config, cloud provider, InstanceGroup list, restConfig, and k8sClient — only when --cloudonly is not set.","commonSituations":"k8sClient is nil (e.g. because kops was built without k8s client support, a known kops case where --cloudonly is implied), mismatched kops/cli and k8s.io/client-go versions, or cloud state contradicting the cluster spec.","solutions":["Check whether k8sClient is nil (kops builds without k8s client imply --cloudonly); pass --cloudonly explicitly","Run the same kops version against a matching cluster spec and retry","Inspect the wrapped cause (%v) for the underlying failure and fix that (e.g. rebuild kops with CGO/client support)","Update kops to the latest patch version if the validator fails deterministically"],"exampleFix":"// before\nkops rolling-update cluster mycluster.k8s.local\n// cannot create cluster validator: unable to create kubernetes client\n// after (skip API validation)\nkops rolling-update cluster mycluster.k8s.local --cloudonly","handlingStrategy":"fallback","validationCode":"// ensure both restConfig and k8sClient are non-nil before validation path\nif restConfig == nil || k8sClient == nil {\n    return errors.New(\"cannot build cluster validator without k8s client; use --cloudonly\")\n}","typeGuard":"func canValidate(restConfig *rest.Config, k8sClient kubernetes.Interface) bool {\n    return restConfig != nil && k8sClient != nil\n}","tryCatchPattern":"clusterValidator, err := validation.NewClusterValidator(cluster, cloud, list, nil, nil, 0, restConfig, k8sClient)\nif err != nil {\n    klog.Warningf(\"cannot create cluster validator: %v; continuing cloudonly\", err)\n    // proceed with cloud-only rolling update instead of aborting\n}","preventionTips":["Use a kops binary built with k8s client support when API validation is desired","Keep kops version aligned with cluster spec version","Run `kops replace --force` style repairs only after checking state store consistency","Have --cloudonly as a documented fallback for validators that cannot initialize"],"tags":["validation","kubernetes","client"],"backgroundTag":"client-initialization-failed","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"}