Skip to content

Commit

Permalink
pkg aws ec2 api: unassign private ip address v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dshehbaj committed Jan 31, 2025
1 parent a92d1ea commit 49abd00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/aws/ec2/api/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,19 +547,19 @@ func (h *ec2APIHelper) AssignIPv4ResourcesAndWaitTillReady(eniID string, resourc

// UnassignIPv4Resources un-assigns IPv4 address or prefix from the interface and waits till it succeeds
func (h *ec2APIHelper) UnassignIPv4Resources(eniID string, resourceType config.ResourceType, resources []string) error {
unassignPrivateIpAddressesInput := &ec2.UnassignPrivateIpAddressesInput{}
unassignPrivateIpAddressesInput := &ec2v2.UnassignPrivateIpAddressesInput{}

// Use respective input param depending on which resource type is being unassigned
switch resourceType {
case config.ResourceTypeIPv4Address:
unassignPrivateIpAddressesInput = &ec2.UnassignPrivateIpAddressesInput{
unassignPrivateIpAddressesInput = &ec2v2.UnassignPrivateIpAddressesInput{
NetworkInterfaceId: &eniID,
PrivateIpAddresses: aws.StringSlice(resources),
PrivateIpAddresses: resources,
}
case config.ResourceTypeIPv4Prefix:
unassignPrivateIpAddressesInput = &ec2.UnassignPrivateIpAddressesInput{
unassignPrivateIpAddressesInput = &ec2v2.UnassignPrivateIpAddressesInput{
NetworkInterfaceId: &eniID,
Ipv4Prefixes: aws.StringSlice(resources),
Ipv4Prefixes: resources,
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/aws/ec2/api/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type EC2Wrapper interface {
DetachNetworkInterface(input *ec2v2.DetachNetworkInterfaceInput) (*ec2v2.DetachNetworkInterfaceOutput, error)
DeleteNetworkInterface(input *ec2v2.DeleteNetworkInterfaceInput) (*ec2v2.DeleteNetworkInterfaceOutput, error)
AssignPrivateIPAddresses(input *ec2v2.AssignPrivateIpAddressesInput) (*ec2v2.AssignPrivateIpAddressesOutput, error)
UnassignPrivateIPAddresses(input *ec2.UnassignPrivateIpAddressesInput) (*ec2.UnassignPrivateIpAddressesOutput, error)
UnassignPrivateIPAddresses(input *ec2v2.UnassignPrivateIpAddressesInput) (*ec2v2.UnassignPrivateIpAddressesOutput, error)
DescribeNetworkInterfaces(input *ec2v2.DescribeNetworkInterfacesInput) (*ec2v2.DescribeNetworkInterfacesOutput, error)
CreateTags(input *ec2v2.CreateTagsInput) (*ec2v2.CreateTagsOutput, error)
DescribeSubnets(input *ec2v2.DescribeSubnetsInput) (*ec2v2.DescribeSubnetsOutput, error)
Expand Down Expand Up @@ -691,9 +691,9 @@ func (e *ec2Wrapper) AssignPrivateIPAddresses(input *ec2v2.AssignPrivateIpAddres
return output, err
}

func (e *ec2Wrapper) UnassignPrivateIPAddresses(input *ec2.UnassignPrivateIpAddressesInput) (*ec2.UnassignPrivateIpAddressesOutput, error) {
func (e *ec2Wrapper) UnassignPrivateIPAddresses(input *ec2v2.UnassignPrivateIpAddressesInput) (*ec2v2.UnassignPrivateIpAddressesOutput, error) {
start := time.Now()
unAssignPrivateIPAddressesOutput, err := e.userServiceClient.UnassignPrivateIpAddresses(input)
output, err := e.userServiceClientV2.UnassignPrivateIpAddresses(context.Background(), input)
ec2APICallLatencies.WithLabelValues("unassign_private_ip").Observe(timeSinceMs(start))

// Metric updates
Expand All @@ -710,7 +710,7 @@ func (e *ec2Wrapper) UnassignPrivateIPAddresses(input *ec2.UnassignPrivateIpAddr
ec2UnassignPrivateIPAddressAPIErrCnt.Inc()
}

return unAssignPrivateIPAddressesOutput, err
return output, err
}

func (e *ec2Wrapper) CreateTags(input *ec2v2.CreateTagsInput) (*ec2v2.CreateTagsOutput, error) {
Expand Down

0 comments on commit 49abd00

Please sign in to comment.