-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛: ec2/byoip: fix EIP leak when creating machine #5039
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -563,21 +563,13 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan | |||||||||||||||||||
|
||||||||||||||||||||
input.NetworkInterfaces = netInterfaces | ||||||||||||||||||||
} else { | ||||||||||||||||||||
if ptr.Deref(i.PublicIPOnLaunch, false) { | ||||||||||||||||||||
input.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{ | ||||||||||||||||||||
{ | ||||||||||||||||||||
DeviceIndex: aws.Int64(0), | ||||||||||||||||||||
SubnetId: aws.String(i.SubnetID), | ||||||||||||||||||||
Groups: aws.StringSlice(i.SecurityGroupIDs), | ||||||||||||||||||||
AssociatePublicIpAddress: i.PublicIPOnLaunch, | ||||||||||||||||||||
}, | ||||||||||||||||||||
} | ||||||||||||||||||||
} else { | ||||||||||||||||||||
input.SubnetId = aws.String(i.SubnetID) | ||||||||||||||||||||
|
||||||||||||||||||||
if len(i.SecurityGroupIDs) > 0 { | ||||||||||||||||||||
input.SecurityGroupIds = aws.StringSlice(i.SecurityGroupIDs) | ||||||||||||||||||||
} | ||||||||||||||||||||
input.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{ | ||||||||||||||||||||
{ | ||||||||||||||||||||
DeviceIndex: aws.Int64(0), | ||||||||||||||||||||
SubnetId: aws.String(i.SubnetID), | ||||||||||||||||||||
Groups: aws.StringSlice(i.SecurityGroupIDs), | ||||||||||||||||||||
AssociatePublicIpAddress: i.PublicIPOnLaunch, | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I see you already set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, preserving the value from machine spec, and forcing to false when EIPPool cluster-api-provider-aws/pkg/cloud/services/ec2/instances.go Lines 185 to 193 in 1313226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main problem in this point is leaving the flag unset (original code), the I may have some scenarios triggered by those tests to review:
Need to review those tests if it is expected or also a bug in the expected return values from API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changes in |
||||||||||||||||||||
}, | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about what I did with registering the instance with the LB: https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/5040/files#diff-0b559bbd149f0e6d54d789235423f66fa8906fdc6ee9c99b9e85db912912011eR622-R629. Just returning an error because the instance is not yet running might confuse users looking at the logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r4f4 that's a great idea, specially now it is generating more warnings with this approach, instead of leak and failures. But non error/warn messages for expected states would be much better.