{"record":{"id":"ba4590adfb9d4b2c","repo":"kubernetes/kops","slug":"spotinst-error-building-cloud-instance-group-v","errorCode":null,"errorMessage":"spotinst: error building cloud instance group: %v","messagePattern":"spotinst: error building cloud instance group: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/spotinst/resources.go","lineNumber":228,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Build all cloud instance groups.\n\tfor _, resource := range resources {\n\n\t\t// Filter out the Ocean resources (they're not needed for now since\n\t\t// we fetch the instances from the launch specs).\n\t\tif ResourceType(resource.Type) == ResourceTypeInstanceGroup {\n\t\t\tif resource.Obj.(InstanceGroup).Type() == InstanceGroupOcean {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// Build cloud instance group.\n\t\tig, err := buildCloudInstanceGroupFromResource(cloud, cluster, instanceGroups, resource, nodeMap)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"spotinst: error building cloud instance group: %v\", err)\n\t\t}\n\t\tif ig == nil {\n\t\t\tif warnUnmatched {\n\t\t\t\tklog.V(2).Infof(\"Found group with no corresponding instance group: %q\", resource.Name)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tcloudInstanceGroups[resource.Name] = ig\n\t}\n\n\treturn cloudInstanceGroups, nil\n}\n\nfunc buildCloudInstanceGroupFromResource(cloud Cloud, cluster *kops.Cluster,\n\tinstanceGroups []*kops.InstanceGroup, resource *resources.Resource,\n\tnodeMap map[string]*v1.Node) (*cloudinstances.CloudInstanceGroup, error,\n) {","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/spotinst/resources.go#L210-L246","documentation":"GetCloudGroups converts Spotinst resources into CloudInstanceGroup objects via buildCloudInstanceGroupFromResource. If that builder returns an error (e.g. the referenced kOps instance group no longer exists or the resource payload is malformed), the error is wrapped with this message and group discovery fails. Without cloud groups, delete/rolling-update flows cannot proceed.","triggerScenarios":"GetCloudGroups (pkg/resources/spotinst/resources.go:228) iterates Spotinst resources and one fails to map: the Spotinst group's name/tag references a kops InstanceGroup deleted from the cluster spec, or buildCloudInstanceGroupFromResource hits a nil/malformed field in the group payload.","commonSituations":"Instance group removed from kOps cluster spec but still exists in Spotinst; name mismatch after renaming an instance group; Spotinst group created manually without proper cluster tags; version drift changing resource field layout.","solutions":["Reconcile the kops instance group spec with the Spotinst groups (`kops get ig`) — recreate or rename to match","Delete the orphaned Spotinst group via the Spotinst console/API","Check the inner %v error to identify the exact field/mapping that failed","Re-run `kops update cluster --yes` to re-sync Spotinst groups with the cluster spec"],"exampleFix":"// before: instance group 'workers' deleted from cluster.yaml but still in Spotinst\n// after\nkops create ig workers -f - <<EOF ... EOF\nkops update cluster --name mycluster --yes","handlingStrategy":"validation","validationCode":"// Confirm every Spotinst group maps to a kops instance group before delete\nfor _, ig := range cluster.Spec.InstanceGroups {\n    klog.V(2).Infof(\"kops ig: %s\", ig.Name) // compare with spotinst group names/tags\n}\n// Orphans (spotinst groups with no matching ig) should be reconciled first via kops update cluster","typeGuard":null,"tryCatchPattern":"groups, err := spotinst.GetCloudGroups(cloud, cluster, instanceGroups, warnUnmatched, nodes)\nif err != nil {\n    if strings.Contains(err.Error(), \"error building cloud instance group\") {\n        klog.Errorf(\"orphaned/mismatched spotinst group; run 'kops update cluster --yes' or remove the group in spotinst console\")\n        return err\n    }\n    return err\n}","preventionTips":["Keep kops instance group spec in sync with Spotinst groups","Delete Spotinst groups before removing them from the cluster spec","Never rename instance groups without running kops update cluster","Ensure Spotinst resources carry the proper cluster tags"],"tags":["spotinst","instance-group","mapping","delete"],"backgroundTag":"cloud-instance-group-mapping-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}