kubernetes/kops · error
spotinst: error listing resources: %v
Error message
spotinst: error listing resources: %v
What it means
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.
Source
Thrown at pkg/resources/spotinst/resources.go:47
"k8s.io/kops/pkg/cloudinstances"
"k8s.io/kops/pkg/resources"
"k8s.io/kops/upup/pkg/fi"
)
// ListResources returns a list of all resources.
func ListResources(cloud Cloud, clusterName string) ([]*resources.Resource, error) {
klog.V(2).Info("Listing all resources")
fns := []func(Cloud, string) ([]*resources.Resource, error){
ListElastigroupResources,
ListOceanResources,
}
var resourceTrackers []*resources.Resource
for _, fn := range fns {
resources, err := fn(cloud, clusterName)
if err != nil {
return nil, fmt.Errorf("spotinst: error listing resources: %v", err)
}
resourceTrackers = append(resourceTrackers, resources...)
}
return resourceTrackers, nil
}
// ListElastigroupResources returns a list of all Elastigroup resources.
func ListElastigroupResources(cloud Cloud, clusterName string) ([]*resources.Resource, error) {
klog.V(2).Info("Listing all Elastigroup resources")
// List all Elastigroup instance groups.
groups, err := listInstanceGroups(cloud.Elastigroup(), clusterName)
if err != nil {
return nil, err
}
View on GitHub (pinned to 4c8573c808)
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
Example fix
// before kops get cluster -o yaml # spotinstToken: expired // after kops create secret secretconfig spotinstToken --from-literal=token.json -f cluster.yaml kops update cluster --yes kops delete cluster --name mycluster
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight Spotinst token validity
req, _ := http.NewRequest("GET", "https://api.spotinst.io/ocean/k8s/cluster", nil)
req.Header.Set("Authorization", "Bearer "+spotinstToken)
resp, err := http.DefaultClient.Do(req)
if err != nil || resp.StatusCode != 200 {
return fmt.Errorf("spotinst credentials invalid; fix token before listing")
} Try / catch
trackers, err := spotinst.ListResources(cloud, clusterName)
if err != nil {
var inner error
if strings.Contains(err.Error(), "spotinst: error listing resources") {
fmt.Sscanf(err.Error(), "spotinst: error listing resources: %v", &inner)
klog.Errorf("spotinst lister failed: %v — check token/network", inner)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- listing IPs for deletion: %w
- got an error while querying for valid regions (verify your A
- spotinst: failed to find launch spec %q: %v
- spotinst: failed to create launch spec: %v
- spotinst: failed to update launch spec: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/9e6f3cf90883c4b7.
Report an issue: GitHub.