Files
floci/src/main/java
BingEdward 8bc4891a9a fix(ec2): report NotFound for launch templates requested by name (#3246)
* fix(ec2): report NotFound for launch templates requested by name

DescribeLaunchTemplates filtered the launch-template collection and
returned whatever matched, so an explicitly requested LaunchTemplateName
that does not exist came back as an empty success. Karpenter creates a
missing launch template only when the lookup fails with
InvalidLaunchTemplateName.NotFoundException, so the empty list read as
"already there" and left EC2NodeClass validation stuck at
launch-template-count=0.

An explicit name or id is now checked against the region's templates
before filtering, mirroring DescribeKeyPairs. Unqualified listings and
filter queries that match nothing still return an empty list.

The lenient scan stays available as matchingLaunchTemplates for the
callers that treat "absent" as an answer: DescribeLaunchTemplateVersions
feeds AutoScaling's own ValidationError for an unresolved template, and
the reconciler must not abort a pass over a group whose template was
deleted.

Fixes #3234

* fix(autoscaling): only treat NotFound as a deleted launch template

The reconciler's launch-template lookup caught every AwsException and
returned null, so any other failure from DescribeLaunchTemplates would
have read as "the template is gone" and silently skipped the group's
scaling instead of surfacing.

Only InvalidLaunchTemplateName.NotFoundException and
InvalidLaunchTemplateId.NotFound mean the template is absent; anything
else now propagates, which reconcileAll already logs per group.

* fix(ec2): use InvalidLaunchTemplateId.NotFound on the mutating paths

DescribeLaunchTemplates reports a missing explicit id as
InvalidLaunchTemplateId.NotFound, while findLaunchTemplate — the lookup
behind ModifyLaunchTemplate, DeleteLaunchTemplate,
CreateLaunchTemplateVersion and resolveLaunchTemplateData — spelled the
identical condition InvalidLaunchTemplateId.NotFoundException, so the two
disagreed on the wire code for the same missing template.

EC2 has no Exception suffix on the id code, only on the name one; that
asymmetry is now noted where it is easy to "correct" by mistake.
2026-09-08 13:30:58 -04:00
..