{"record":{"id":"f985b9efd43293dc","repo":"kubernetes/kops","slug":"spotinst-failed-to-update-launch-spec-v","errorCode":null,"errorMessage":"spotinst: failed to update launch spec: %v","messagePattern":"spotinst: failed to update launch spec: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go","lineNumber":895,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Update the existing Cluster.\n\t\tif err = cloud.Spotinst().Ocean().Update(ctx, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Wrap the raw object as a Launch Spec.\n\tsp, err := spotinst.NewLaunchSpec(cloud.ProviderID(), spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Update the existing Launch Spec.\n\tif err = cloud.Spotinst().LaunchSpec().Update(ctx, sp); err != nil {\n\t\treturn fmt.Errorf(\"spotinst: failed to update launch spec: %v\", err)\n\t}\n\n\treturn nil\n}\n\ntype terraformLaunchSpec struct {\n\tName    *string                  `cty:\"name\"`\n\tOceanID *terraformWriter.Literal `cty:\"ocean_id\"`\n\n\tMonitoring               *bool                              `cty:\"monitoring\"`\n\tEBSOptimized             *bool                              `cty:\"ebs_optimized\"`\n\tImageID                  *string                            `cty:\"image_id\"`\n\tAssociatePublicIPAddress *bool                              `cty:\"associate_public_ip_address\"`\n\tRestrictScaleDown        *bool                              `cty:\"restrict_scale_down\"`\n\tRootVolumeSize           *int64                             `cty:\"root_volume_size\"`\n\tUserData                 *terraformWriter.Literal           `cty:\"user_data\"`\n\tIAMInstanceProfile       *terraformWriter.Literal           `cty:\"iam_instance_profile\"`\n\tKeyName                  *terraformWriter.Literal           `cty:\"key_name\"`","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go#L877-L913","documentation":"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.","triggerScenarios":"During createOrUpdate after a diff produces changes, LaunchSpec().Update(ctx, sp) fails (invalid field combination, API auth, concurrent modification).","commonSituations":"Applying an invalid change (e.g. unsupported instance type for the ocean); stale/invalid Spotinst token; Spotinst API temporarily unavailable.","solutions":["Inspect the wrapped %v error for the API's rejection reason","Reduce the change set (update one field at a time) to isolate the invalid field","Re-authenticate/refresh the Spotinst token","Retry after transient API errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"diff := computeChanges(actual, expected)\nfor field := range diff {\n    if !updatableFields[field] {\n        return fmt.Errorf(\"field %q is not updatable; recreate the launch spec instead\", field)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := svc.Update(ctx, sp); err != nil {\n    if isTransient(err) {\n        // retry with exponential backoff\n    }\n    return fmt.Errorf(\"spotinst: failed to update launch spec: %w\", err)\n}","preventionTips":["Update one field at a time to isolate invalid combinations","Verify new instance types are supported in the Ocean's region","Refresh tokens when updates suddenly fail with auth errors","Re-check the spec in the console after failed updates for partial changes"],"tags":["spotinst","launch-spec","api-error","update"],"backgroundTag":"spotinst-api-error","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}