kubernetes/kops · error

spotinst: failed to find launch spec %q: %v

Error message

spotinst: failed to find launch spec %q: %v

What it means

LaunchSpec.find lists all launch specs under a Spotinst Ocean to locate the one managed by this kops task. If the Spotinst API List call itself fails, the underlying error is wrapped and rethrown. This is a Spotinst API communication failure, not a missing resource.

Source

Thrown at upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go:109

	}

	if o.Ocean != nil {
		deps = append(deps, o.Ocean)
	}

	if o.UserData != nil {
		deps = append(deps, fi.FindDependencies(tasks, o.UserData)...)
	}

	return deps
}

func (o *LaunchSpec) find(svc spotinst.LaunchSpecService, oceanID string) (*aws.LaunchSpec, error) {
	klog.V(4).Infof("Attempting to find LaunchSpec: %q", fi.ValueOf(o.Name))

	specs, err := svc.List(context.Background(), oceanID)
	if err != nil {
		return nil, fmt.Errorf("spotinst: failed to find launch spec %q: %v", fi.ValueOf(o.Name), err)
	}
	if len(specs) == 0 {
		return nil, fmt.Errorf("spotinst: no launch specs associated with ocean %q", oceanID)
	}

	var out *aws.LaunchSpec
	for _, spec := range specs {
		if spec.Name() == fi.ValueOf(o.Name) {
			out = spec.Obj().(*aws.LaunchSpec)
			break
		}
	}
	if out == nil {
		return nil, fmt.Errorf("spotinst: failed to find launch spec %q", fi.ValueOf(o.Name))
	}

	klog.V(4).Infof("LaunchSpec/%s: %s", fi.ValueOf(o.Name), stringutil.Stringify(out))
	return out, nil

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check SPOTINST_TOKEN / SPOTINST_ACCOUNT environment variables are valid
  2. Verify network connectivity to the Spotinst API endpoint
  3. Confirm the Ocean still exists in the Spotinst console
  4. Retry after rate-limit/throttle backoff
Defensive patterns

Strategy: retry

Validate before calling

if os.Getenv("SPOTINST_TOKEN") == "" || os.Getenv("SPOTINST_ACCOUNT") == "" {
    return errors.New("SPOTINST_TOKEN and SPOTINST_ACCOUNT must be set")
}

Try / catch

specs, err := svc.List(ctx, oceanID)
if err != nil {
    // retry with backoff for transient API/network errors
    if attempt < maxRetries {
        time.Sleep(backoff)
        continue
    }
    return fmt.Errorf("spotinst list launch specs failed after retries: %w", err)
}

Prevention

When it happens

Trigger: During Find or update of a LaunchSpec task, svc.List(ctx, oceanID) returns an error (API auth failure, network error, invalid ocean ID, rate limiting).

Common situations: Expired or invalid Spotinst API token; Spotinst API outage; network/proxy issues from CI runner; ocean ID stale after cluster was deleted.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/c2f8f06eb437d1cf. Report an issue: GitHub.