kubernetes/kops · error
unexpected error creating validatior: %v
Error message
unexpected error creating validatior: %v
What it means
This error is returned when validation.NewClusterValidator fails to assemble the cluster validator, which needs the cluster spec, cloud provider, instance group list, filters, rest config, and k8s client. The message (note the 'validatior' typo) indicates a programming/config-level problem inside the validation package, not a cluster health issue. It uses %v rather than %w, so the cause cannot be unwrapped programmatically.
Source
Thrown at cmd/kops/validate_cluster.go:184
if err != nil {
return nil, fmt.Errorf("getting rest config: %w", err)
}
httpClient, err := f.HTTPClient(restConfig)
if err != nil {
return nil, fmt.Errorf("getting http client: %w", err)
}
k8sClient, err := kubernetes.NewForConfigAndClient(restConfig, httpClient)
if err != nil {
return nil, fmt.Errorf("building kubernetes client: %w", err)
}
timeout := time.Now().Add(options.wait)
validator, err := validation.NewClusterValidator(cluster, cloud, list, options.filterInstanceGroups, options.filterPodsForValidation, options.MaxUnreadyNodes, restConfig, k8sClient)
if err != nil {
return nil, fmt.Errorf("unexpected error creating validatior: %v", err)
}
consecutive := 0
for {
if options.wait > 0 && time.Now().After(timeout) && consecutive == 0 {
return nil, fmt.Errorf("wait time exceeded during validation")
}
result, err := validator.Validate(ctx)
if err != nil {
consecutive = 0
if options.wait > 0 {
klog.Warningf("(will retry): unexpected error during validation: %v", err)
time.Sleep(options.interval)
continue
} else {
return nil, fmt.Errorf("unexpected error during validation: %v", err)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Re-run `kops export kubecfg <cluster>` and verify `kops get cluster` returns a complete spec before validating.
- Check the printed %v cause — validate the cluster spec fields it names (e.g. missing kubeAPI config).
- Ensure cloud credentials are present (AWS/GCP/etc. env or profile) since the validator needs the cloud handle.
- Retry after a completed `kops update cluster --yes` so state store and cloud resources are consistent.
- Upgrade kops — constructor signature/behavior changed across versions; a stale binary against a newer state store can fail here.
Example fix
// before
validator, err := validation.NewClusterValidator(cluster, cloud, list, ...)
if err != nil {
return nil, fmt.Errorf("unexpected error creating validatior: %v", err)
}
// after
validator, err := validation.NewClusterValidator(cluster, cloud, list, ...)
if err != nil {
return nil, fmt.Errorf("unexpected error creating validator: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
cluster, err := clientset.GetCluster(ctx, clusterName)
if err != nil { return err }
if cloud == nil { return errors.New("cloud handle unavailable: check cloud credentials") }
if len(instanceGroups.Items) == 0 { return errors.New("no instance groups found") } Type guard
func canBuildValidator(cluster *kops.Cluster, cloud cloudproviders.Cloud, igs *kops.InstanceGroupList) bool {
return cluster != nil && cluster.Spec.KubernetesAPIAccess != nil && cloud != nil && len(igs.Items) > 0
} Prevention
- Complete `kops update cluster --yes` before validating.
- Ensure cloud provider credentials are exported (AWS_PROFILE/GCP creds etc.).
- Verify `kops get cluster <name>` returns a full spec, not a stub.
- Keep kops binary version aligned with the cluster state store version.
When it happens
Trigger: Calling validation.NewClusterValidator with an incomplete cluster object, nil cloud provider, missing instance groups, or invalid restConfig/k8sClient combination that the validator constructor rejects (e.g. missing discovery client inputs).
Common situations: Running `kops validate cluster` against a cluster whose state store entry is partially written; cluster object missing required spec fields after a failed update; cloud API credentials absent so cloud handle is unusable.
Related errors
- invalid InstanceGroup name: %v
- cluster not yet healthy
- cannot get pod health for %q: %v
- failed to parse apiVersion %q
- failed to find kind in object
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/fe8f3b44e1482a42.
Report an issue: GitHub.