Skip to content

Controllers Interrupted During Reconcile Create Duplicate Resources #2062

@nromriell

Description

@nromriell

Edited: Removed ec2 specification, Upon further investigation this would be true for all controllers

Describe the bug
During the reconcile of a VPC if the controller is interrupted before the reconcile completes, on restart the VPC is created a second time.

This is because the status on the VPC is empty and not updated to track the remote resource until after reconciliation is completed. This leads to orphaned duplicate resources

Steps to reproduce

  • Create a new VPC object
apiVersion: ec2.services.k8s.aws/v1alpha1
kind: VPC
metadata:
  name: example
spec:
  ...
  • As soon as the creation for the vpc is trigger on the remote, stop or restart the controller
  • Check the the status on the vpc, if the condition has triggered the status will still be empty with no reference to the remote
  • When the controller runs the reconcile again a new object with the same information will be created

This was found because of a panic on the controller causing a restart during the reconcile of the VPC causing the interrupt during creation

{"level":"info","ts":"2024-04-24T18:00:29.176Z","msg":"Observed a panic in reconciler: runtime error: invalid memory address or nil pointer dereference","controller":"elasticipaddress",...}

Expected outcome
VPC status is tracked as pending before final status update on crd after creation is complete. The controller would attempt to then reconcile with remote before creating a new object

Environment
EKS version: eks.15
Kubernetes Version: 1.27
Service Targeted: EC2
EC2 ACK Controller Version: 1.2.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    service/ec2Indicates issues or PRs that are related to ec2-controller.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions