{"record":{"id":"39762267b3d0c66d","repo":"kubernetes/kops","slug":"spotinst-unable-to-resolve-image-q-v","errorCode":null,"errorMessage":"spotinst: unable to resolve image %q: %v","messagePattern":"spotinst: unable to resolve image %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go","lineNumber":1876,"sourceCode":"\t}\n\n\tif e.Orientation == nil || (e.Orientation != nil && fi.ValueOf(e.Orientation) == \"\") {\n\t\te.Orientation = new(\"balanced\")\n\t}\n\n\tif e.Monitoring == nil {\n\t\te.Monitoring = new(false)\n\t}\n\n\tif e.HealthCheckType == nil {\n\t\te.HealthCheckType = new(\"K8S_NODE\")\n\t}\n}\n\nfunc resolveImage(cloud awsup.AWSCloud, name string) (*ec2types.Image, error) {\n\timage, err := cloud.ResolveImage(name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"spotinst: unable to resolve image %q: %v\", name, err)\n\t} else if image == nil {\n\t\treturn nil, fmt.Errorf(\"spotinst: unable to resolve image %q: not found\", name)\n\t}\n\n\treturn image, nil\n}\n\nfunc subnetSlicesEqualIgnoreOrder(l, r []*awstasks.Subnet) bool {\n\tvar lIDs []string\n\tfor _, s := range l {\n\t\tlIDs = append(lIDs, *s.ID)\n\t}\n\n\tvar rIDs []string\n\tfor _, s := range r {\n\t\tif s.ID == nil {\n\t\t\tklog.V(4).Infof(\"Subnet ID not set; returning not-equal: %v\", s)\n\t\t\treturn false","sourceCodeStart":1858,"sourceCodeEnd":1894,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go#L1858-L1894","documentation":"resolveImage resolves an AMI by name/id via cloud.ResolveImage; a resolution failure or nil result is wrapped with the image name. This maps a spec image (e.g. an AMI alias or name) to an actual EC2 Image for the spotinst elastigroup.","triggerScenarios":"During Elastigroup rendering, resolveImage(cloud, name) is called with the configured image; ResolveImage returns an error (bad AMI id format, describe-images API failure) or returns nil (no matching image in the region).","commonSituations":"Hardcoded AMI from another region; deprecated/EOL kOps AMI removed from the region; typo'd image alias; AMI made private or deregistered; using a Debian/Ubuntu name that doesn't exist for the region.","solutions":["Check the image name/AMI id in the spec; if it's an ami-xxx id, verify it exists in the cluster region (aws ec2 describe-images --image-ids ...).","Remove a pinned ami and let kOps pick the default image for the Kubernetes version and channel (omit the image field).","If the AMI exists but is private, share it with the account or copy it into the target region.","Re-run `kops update cluster` after fixing the image value."],"exampleFix":"// before: AMI from wrong region\nimage: ami-0abcdef1234567890\n// after: let kOps resolve the default image for the channel/k8s version\n# remove the image field, or use a valid alias:\nimage: ubuntu-22.04-amd64","handlingStrategy":"validation","validationCode":"// resolve the image up front and fail with a clear message\nimg, err := cloud.ResolveImage(name)\nif err != nil {\n    return fmt.Errorf(\"image %q unresolvable: %v — omit `image` to use the kOps default\", name, err)\n}\nif img == nil {\n    return fmt.Errorf(\"image %q not found in region %s — pick a region-valid alias or AMI\", name, region)\n}","typeGuard":null,"tryCatchPattern":"image, err := resolveImage(cloud, name)\nif err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        // fall back to the default image for the k8s version\n        return defaultImageFor(kubernetesVersion, arch)\n    }\n    return err\n}","preventionTips":["Avoid hardcoding ami- ids; omit `image` or use kOps image aliases","Verify pinned AMIs exist in the cluster region before upgrading","Watch for EOL notices — old kOps AMIs are eventually removed","Validate with `aws ec2 describe-images` or `kops toolbox instance-selector`"],"tags":["spotinst","aws","ami","image-resolution"],"backgroundTag":"ami-not-found","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"}