-
Notifications
You must be signed in to change notification settings - Fork 271
Description
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
- alternatively place an interrupt inside the code between create and object update https://github.com/aws-controllers-k8s/ec2-controller/blob/main/pkg/resource/vpc/sdk.go#L266
resp, err = rm.sdkapi.CreateVpcWithContext(ctx, input) rm.metrics.RecordAPICall("CREATE", "CreateVpc", err) if err != nil { return nil, err } panic("interrupt to orphan")
- alternatively place an interrupt inside the code between create and object update https://github.com/aws-controllers-k8s/ec2-controller/blob/main/pkg/resource/vpc/sdk.go#L266
- 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