Repository navigation
Description
Bug Description
When an EC2 LaunchTemplate CR is annotated with services.k8s.aws/adoption-policy: adopt-or-create and a LaunchTemplate with the same name already exists in AWS (but Status.ID is not yet populated in the CR), the controller enters a permanent Recoverable error loop instead of adopting the existing resource.
The root cause is that sdkFind returns NotFound early whenever Status.ID is nil, and newListRequestPayload never looks up by name — so adopt-or-create has no path to discover the pre-existing AWS resource by name.
Steps to Reproduce
-
Have a LaunchTemplate already present in AWS (e.g. after a control-plane migration where the Kubernetes objects were lost but AWS resources were retained with
deletion-policy: retain). -
Create a
LaunchTemplateCR with the same name and theadopt-or-createannotation, but without a pre-populatedStatus.ID:
apiVersion: ec2.services.k8s.aws/v1alpha1
kind: LaunchTemplate
metadata:
name: my-cluster-general-ng
annotations:
services.k8s.aws/adoption-policy: adopt-or-create
services.k8s.aws/deletion-policy: retain
spec:
name: my-cluster-general-ng
launchTemplateData:
instanceType: m6g.large
# ... other fields- Observe the CR status — the controller never adopts the existing LaunchTemplate and instead repeats
CreateLaunchTemplatecalls that fail:
status:
conditions:
- message: 'api error InvalidLaunchTemplateName.AlreadyExistsException: Launch template
name already in use.'
status: "True"
type: ACK.Recoverable
- message: Unable to determine if desired resource state matches latest observed state
reason: 'operation error EC2: CreateLaunchTemplate, ..., InvalidLaunchTemplateName.AlreadyExistsException:
Launch template name already in use.'
status: Unknown
type: ACK.ResourceSyncedThis error loops indefinitely — the resource is never adopted.
Root Cause Analysis
hooks.go line 242–243 — checkForMissingRequiredFields gates sdkFind exclusively on Status.ID:
func (rm *resourceManager) checkForMissingRequiredFields(r *resource) bool {
return r.ko.Status.ID == nil
}sdk.go line 168–180 — newListRequestPayload only populates LaunchTemplateIds; when Status.ID is nil, the struct is empty and the function returns early from sdkFind:
func (rm *resourceManager) newListRequestPayload(r *resource) (*svcsdk.DescribeLaunchTemplatesInput, error) {
res := &svcsdk.DescribeLaunchTemplatesInput{}
if r.ko.Status.ID != nil {
res.LaunchTemplateIds = []string{*r.ko.Status.ID}
}
return res, nil // empty input when ID is nil — DescribeLaunchTemplates without filters returns ALL templates
}sdk.go line 70–71 — sdkFind exits immediately with ackerr.NotFound before even calling DescribeLaunchTemplates:
if rm.requiredFieldsMissingFromReadManyInput(r) {
return nil, ackerr.NotFound // ← always true when Status.ID is nil
}The failure chain with adopt-or-create:
CR created (Status.ID = nil)
→ sdkFind() → checkForMissingRequiredFields() = true → returns NotFound
→ adopt-or-create sees NotFound → calls sdkCreate()
→ AWS: InvalidLaunchTemplateName.AlreadyExistsException
→ ACK marks condition ACK.Recoverable, retries
→ loop forever
Note: DescribeLaunchTemplates supports filtering by LaunchTemplateNames, so a name-based lookup is possible. The hooks.go already uses Spec.Name in newUpdateLaunchTemplateVersionRequestPayload (line 204). But sdkFind / newListRequestPayload never use it.
Expected Behaviour
When adoption-policy: adopt-or-create is set and a LaunchTemplate with the same Spec.Name already exists in AWS, sdkFind should attempt a DescribeLaunchTemplates call filtered by LaunchTemplateNames: [Spec.Name] before concluding the resource doesn't exist. If found, the controller should adopt it (populate Status.ID, set ACK.ResourceSynced: True).
Suggested Fix
In checkForMissingRequiredFields / newListRequestPayload — when Status.ID is nil, fall through to a name-based DescribeLaunchTemplates lookup using Spec.Name instead of short-circuiting to NotFound.
Alternatively, a custom pre-create hook that resolves the existing LaunchTemplate ID by name and populates Status.ID before sdkCreate is called would achieve the same result.
Environment
- ACK ec2-controller version: v1.15.0 (latest as of 2026-06-19)
- Kubernetes: EKS 1.35
- AWS Region: eu-central-1
- Observed with: kro RGDs using
adopt-or-createon LaunchTemplate resources (the annotation is set at the template level in the RGD, soStatus.IDis never pre-populated)
Related Issues
- Adopt existing resources without requiring resourceID in adoption field #2762 — Adopt existing resources without requiring resourceID in
adoption-fields(similar concept for VPC) - Ack with Kro RGDs and adopt-or-create annotations causes constant reconcile loops #2728 — ACK + kro +
adopt-or-createreconcile loops (different root cause, RDS KMS alias normalization)
Activity
github-actions commentedon Jun 19, 2026
Hello @jbreitenbaumer 👋 Thank you for opening an issue in ACK! A maintainer will triage this issue soon.
We encourage community contributions, so if you're interested in tackling this yourself or suggesting a solution, please check out our Contribution and Code of Conduct guidelines.
You can find more information about ACK on our website.
fix: key LaunchTemplate by Name so adopt-or-create works
fix: key LaunchTemplate by Name so adopt-or-create works
fix: key LaunchTemplate by Name so adopt-or-create works
fix: key LaunchTemplate by Name so adopt-or-create works
fix: key LaunchTemplate by Name so adopt-or-create works