{"record":{"id":"9e6f3cf90883c4b7","repo":"kubernetes/kops","slug":"spotinst-error-listing-resources-v","errorCode":null,"errorMessage":"spotinst: error listing resources: %v","messagePattern":"spotinst: error listing resources: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/spotinst/resources.go","lineNumber":47,"sourceCode":"\t\"k8s.io/kops/pkg/cloudinstances\"\n\t\"k8s.io/kops/pkg/resources\"\n\t\"k8s.io/kops/upup/pkg/fi\"\n)\n\n// ListResources returns a list of all resources.\nfunc ListResources(cloud Cloud, clusterName string) ([]*resources.Resource, error) {\n\tklog.V(2).Info(\"Listing all resources\")\n\n\tfns := []func(Cloud, string) ([]*resources.Resource, error){\n\t\tListElastigroupResources,\n\t\tListOceanResources,\n\t}\n\n\tvar resourceTrackers []*resources.Resource\n\tfor _, fn := range fns {\n\t\tresources, err := fn(cloud, clusterName)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"spotinst: error listing resources: %v\", err)\n\t\t}\n\n\t\tresourceTrackers = append(resourceTrackers, resources...)\n\t}\n\n\treturn resourceTrackers, nil\n}\n\n// ListElastigroupResources returns a list of all Elastigroup resources.\nfunc ListElastigroupResources(cloud Cloud, clusterName string) ([]*resources.Resource, error) {\n\tklog.V(2).Info(\"Listing all Elastigroup resources\")\n\n\t// List all Elastigroup instance groups.\n\tgroups, err := listInstanceGroups(cloud.Elastigroup(), clusterName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/spotinst/resources.go#L29-L65","documentation":"ListResources for Spotinst runs a list of per-resource-type listing functions (fns) and aggregates their trackers. If any listing function returns an error, listing aborts with this wrapped message. It is a wrapper — the root cause is inside the specific Spotinst resource lister (Elastigroup/Ocean etc.) or the Spotinst API itself.","triggerScenarios":"Calling ListResources (pkg/resources/spotinst/resources.go:47) — via ListSpotinstResources or GetCloudGroups — when one of the fns (e.g. listing instances, launch specs, or groups via the Spotinst API) fails due to invalid Spotinst API token, deleted Spotinst account, or API outage.","commonSituations":"Expired/rotated Spotinst API credentials in the cluster spec; Spotinst organization token invalidated; network/proxy blocking api.spotinst.com; Spotinst group already deleted in the console while kOps state still references it.","solutions":["Verify the Spotinst token/account in the cluster config (spotinstToken/spotinstAccount secret) is valid with `curl` against the Spotinst API","Re-run after confirming api.spotinst.com reachability (proxy/firewall)","Check the inner %v error printed with this message to identify which lister failed","Delete the stale Spotinst group in the Spotinst console if it no longer exists, then retry"],"exampleFix":"// before\nkops get cluster -o yaml # spotinstToken: expired\n// after\nkops create secret secretconfig spotinstToken --from-literal=token.json -f cluster.yaml\nkops update cluster --yes\nkops delete cluster --name mycluster","handlingStrategy":"try-catch","validationCode":"// Pre-flight Spotinst token validity\nreq, _ := http.NewRequest(\"GET\", \"https://api.spotinst.io/ocean/k8s/cluster\", nil)\nreq.Header.Set(\"Authorization\", \"Bearer \"+spotinstToken)\nresp, err := http.DefaultClient.Do(req)\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"spotinst credentials invalid; fix token before listing\")\n}","typeGuard":null,"tryCatchPattern":"trackers, err := spotinst.ListResources(cloud, clusterName)\nif err != nil {\n    var inner error\n    if strings.Contains(err.Error(), \"spotinst: error listing resources\") {\n        fmt.Sscanf(err.Error(), \"spotinst: error listing resources: %v\", &inner)\n        klog.Errorf(\"spotinst lister failed: %v — check token/network\", inner)\n    }\n    return err\n}","preventionTips":["Rotate and validate Spotinst tokens before operations","Ensure api.spotinst.com is reachable (proxy/firewall)","Keep spotinst-sdk-go versions aligned with kOps","Remove Spotinst groups deleted out-of-band from kOps state"],"tags":["spotinst","api-error","credentials","wrapper"],"backgroundTag":"cloud-api-list-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"}