{"record":{"id":"df167f0c368aafc0","repo":"kubernetes/kops","slug":"converting-cluster-object-w-df167f","errorCode":null,"errorMessage":"converting cluster object: %w","messagePattern":"converting cluster object: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/controllers/clusterapi/kopsconfig_controller.go","lineNumber":192,"sourceCode":"func (r *KopsConfigReconciler) buildBootstrapData(ctx context.Context, cluster *kopsapi.Cluster, kopsControlPlane *capikops.KopsControlPlane) ([]byte, error) {\n\twellKnownAddresses := model.WellKnownAddresses{}\n\tfor _, systemEndpoint := range kopsControlPlane.Status.SystemEndpoints {\n\t\tswitch systemEndpoint.Type {\n\t\tcase capikops.SystemEndpointTypeKopsController:\n\t\t\twellKnownAddresses[wellknownservices.KopsController] = append(wellKnownAddresses[wellknownservices.KopsController], systemEndpoint.Endpoint)\n\t\tcase capikops.SystemEndpointTypeKubeAPIServer:\n\t\t\twellKnownAddresses[wellknownservices.KubeAPIServer] = append(wellKnownAddresses[wellknownservices.KubeAPIServer], systemEndpoint.Endpoint)\n\t\t}\n\t}\n\n\tclusterInternal := &kops.Cluster{}\n\n\tconfigBuilder := &commands.ConfigBuilder{}\n\tconfigBuilder.Clientset = r.clientset\n\n\t{\n\t\tif err := kopscodecs.Scheme.Convert(cluster, clusterInternal, nil); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"converting cluster object: %w\", err)\n\t\t}\n\t\t// TODO: Fix validation\n\t\tclusterInternal.Namespace = \"\"\n\n\t\tconfigBuilder.Cluster = clusterInternal\n\t\tconfigBuilder.ClusterName = clusterInternal.Name\n\t}\n\n\tig := &kops.InstanceGroup{}\n\t{\n\t\tig.SetName(\"placeholder-ig-name\") // IG name is not used for nodeup config generation\n\t\tig.Spec.Role = kops.InstanceGroupRoleNode\n\t\t// The machine image is chosen by the CAPI infrastructure provider and is not used for\n\t\t// nodeup config generation; the placeholder avoids resolving a default from the channel.\n\t\tig.Spec.Image = \"placeholder-image\"\n\n\t\tconfigBuilder.InstanceGroup = ig\n\t\tconfigBuilder.InstanceGroupName = ig.Name","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/controllers/clusterapi/kopsconfig_controller.go#L174-L210","documentation":"Thrown by buildBootstrapData when the kops scheme codec (kopscodecs.Scheme.Convert) cannot convert the external v1alpha2 kops Cluster object into the internal kops.Cluster representation. Conversion failures mean the external object contains fields/values that cannot be losslessly mapped to the internal API, typically because the object came from a different kops version than the controller binary.","triggerScenarios":"The Cluster spec stored in the management cluster was created by a different kops version than the controller (field type changes, removed/renamed fields), the object is partially written or corrupted, or a round-trip conversion hook returns an error for an unrecognized field value.","commonSituations":"Upgrading the kops cluster-api controllers while old Cluster objects created by a previous version still exist; hand-edited Cluster YAML with invalid enum values; mixed controller replicas running different kops versions against the same management cluster.","solutions":["Read the wrapped conversion error to identify the offending field/value.","Upgrade or downgrade the kops cluster-api controller binary to match the kops version used to create the Cluster object.","Re-apply the Cluster object using kubectl/kops from the controller's matching version so defaults and field formats are consistent.","If a replica set is running mixed versions, align all controller pods to one kops version (check image tags in the deployment).","As a last resort, recreate the Cluster object from the authoritative kops cluster configuration export."],"exampleFix":"// before: controller image pinned to old kops version\nimage: ko.k8s.io/kops-clusterapi-controller:v3.1.0\n// after: match controller version to the kops version that created the Cluster\nimage: ko.k8s.io/kops-clusterapi-controller:v3.2.0","handlingStrategy":"validation","validationCode":"// Validate the external Cluster converts cleanly before the controller does\nclusterInternal := &kops.Cluster{}\nif err := kopscodecs.Scheme.Convert(cluster, clusterInternal, nil); err != nil {\n\treturn fmt.Errorf(\"cluster %s/%s not convertible with this controller version: %w\", cluster.Namespace, cluster.Name, err)\n}\n// Also pin controller version to the kops version that created the object","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the kops cluster-api controller image version to the same kops release used to create Cluster objects.","Upgrade CRs and controllers together; never run mixed-version replicas of the controller.","Validate Cluster specs with kops (kops replace/validate) before storing them in the management cluster.","Test conversions in CI with a snapshot of production Cluster objects when bumping kops versions.","Avoid hand-editing kops CRs; generate them from kops tooling."],"tags":["kubernetes","kops","conversion","api-versioning","controller"],"backgroundTag":"scheme-conversion-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"}