Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cloud/services/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ func (s *Service) GetDHCPOptionSetDomainName(ec2client common.EC2API, vpcID *str

dhcpResult, err := ec2client.DescribeDhcpOptions(context.TODO(), dhcpInput)
if err != nil {
log.Error(err, "failed to describe DHCP Options Set", "DhcpOptionsSet", *dhcpResult)
log.Error(err, "failed to describe DHCP Options Set", "input", *dhcpInput)
return nil
}

Expand Down
32 changes: 32 additions & 0 deletions pkg/cloud/services/ec2/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,19 @@ func TestGetDHCPOptionSetDomainName(t *testing.T) {
expectedPrivateDNSName: nil,
mockCalls: mockedGetPrivateDNSDomainNameFromDHCPOptionsEmptyCalls,
},
{
name: "DescribeDhcpOptions call returns error, e.g. because it is denied by IAM policy",
vpcID: "vpc-exists",
dhcpOpt: &types.DhcpOptions{
DhcpConfigurations: []types.DhcpConfiguration{
{
Key: aws.String("domain-name"),
},
},
},
expectedPrivateDNSName: nil,
mockCalls: mockedGetPrivateDNSDomainNameFromDHCPOptionsErrorCalls,
},
}
for _, tc := range testsCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -6464,6 +6477,25 @@ func mockedGetPrivateDNSDomainNameFromDHCPOptionsEmptyCalls(m *mocks.MockEC2APIM
}, nil)
}

func mockedGetPrivateDNSDomainNameFromDHCPOptionsErrorCalls(m *mocks.MockEC2APIMockRecorder) {
m.DescribeVpcs(context.TODO(), &ec2.DescribeVpcsInput{
VpcIds: []string{"vpc-exists"},
}).Return(&ec2.DescribeVpcsOutput{
Vpcs: []types.Vpc{
{
VpcId: aws.String("vpc-exists"),
CidrBlock: aws.String("10.0.0.0/16"),
IsDefault: aws.Bool(false),
State: types.VpcStateAvailable,
DhcpOptionsId: aws.String("dopt-12345678"),
},
},
}, nil)
m.DescribeDhcpOptions(context.TODO(), &ec2.DescribeDhcpOptionsInput{
DhcpOptionsIds: []string{"dopt-12345678"},
}).Return(nil, errors.New("some error"))
}

func TestGetCapacityReservationSpecification(t *testing.T) {
mockCapacityReservationID := "cr-123"
mockCapacityReservationIDPtr := &mockCapacityReservationID
Expand Down
Loading