kubernetes/kops · error

spotinst: failed to update launch spec: %v

Error message

spotinst: failed to update launch spec: %v

What it means

Thrown in the update path when cloud.Spotinst().LaunchSpec().Update fails to push the modified launch spec object to Spotinst. It fires after the spec was found and wrapped successfully, so the failure is in the Spotinst API write: invalid field values rejected by the API, stale spec version, credential issues, or a transient API error.

Source

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

		if err != nil {
			return err
		}

		// Update the existing Cluster.
		if err = cloud.Spotinst().Ocean().Update(ctx, o); err != nil {
			return err
		}
	}

	// Wrap the raw object as a Launch Spec.
	sp, err := spotinst.NewLaunchSpec(cloud.ProviderID(), spec)
	if err != nil {
		return err
	}

	// Update the existing Launch Spec.
	if err = cloud.Spotinst().LaunchSpec().Update(ctx, sp); err != nil {
		return fmt.Errorf("spotinst: failed to update launch spec: %v", err)
	}

	return nil
}

type terraformLaunchSpec struct {
	Name    *string                  `cty:"name"`
	OceanID *terraformWriter.Literal `cty:"ocean_id"`

	Monitoring               *bool                              `cty:"monitoring"`
	EBSOptimized             *bool                              `cty:"ebs_optimized"`
	ImageID                  *string                            `cty:"image_id"`
	AssociatePublicIPAddress *bool                              `cty:"associate_public_ip_address"`
	RestrictScaleDown        *bool                              `cty:"restrict_scale_down"`
	RootVolumeSize           *int64                             `cty:"root_volume_size"`
	UserData                 *terraformWriter.Literal           `cty:"user_data"`
	IAMInstanceProfile       *terraformWriter.Literal           `cty:"iam_instance_profile"`
	KeyName                  *terraformWriter.Literal           `cty:"key_name"`

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped %v error for the API's rejection reason
  2. Reduce the change set (update one field at a time) to isolate the invalid field
  3. Re-authenticate/refresh the Spotinst token
  4. Retry after transient API errors
Defensive patterns

Strategy: retry

Validate before calling

diff := computeChanges(actual, expected)
for field := range diff {
    if !updatableFields[field] {
        return fmt.Errorf("field %q is not updatable; recreate the launch spec instead", field)
    }
}

Try / catch

if err := svc.Update(ctx, sp); err != nil {
    if isTransient(err) {
        // retry with exponential backoff
    }
    return fmt.Errorf("spotinst: failed to update launch spec: %w", err)
}

Prevention

When it happens

Trigger: During createOrUpdate after a diff produces changes, LaunchSpec().Update(ctx, sp) fails (invalid field combination, API auth, concurrent modification).

Common situations: Applying an invalid change (e.g. unsupported instance type for the ocean); stale/invalid Spotinst token; Spotinst API temporarily unavailable.

Related errors


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