Skip to content

Commit

Permalink
CFE-1064: Add support for placementGroupPartition
Browse files Browse the repository at this point in the history
Signed-off-by: chiragkyal <ckyal@redhat.com>
  • Loading branch information
chiragkyal committed Jun 26, 2024
1 parent 2b57d70 commit 6b515c0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/actuators/machine/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ func constructInstancePlacement(machine *machinev1beta1.Machine, machineProvider

if machineProviderConfig.PlacementGroupName != "" {
placement.GroupName = &machineProviderConfig.PlacementGroupName

if machineProviderConfig.PlacementGroupPartition != 0 {
placement.PartitionNumber = aws.Int64(int64(machineProviderConfig.PlacementGroupPartition))
}
}

instanceTenancy := machineProviderConfig.Placement.Tenancy
Expand Down
36 changes: 36 additions & 0 deletions pkg/actuators/machine/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,42 @@ func TestLaunchInstance(t *testing.T) {
},
},
},
{
name: "With custom placement group name and partition number",
providerConfig: stubInstancePlacementGroupPartition("placement-group1", 4),
subnetOutput: stubDescribeSubnetsOutputProvided(aws.StringValue(providerConfig.Subnet.ID)),
zonesOutput: stubDescribeAvailabilityZonesOutputDefault(),
runInstancesInput: &ec2.RunInstancesInput{
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
Name: aws.String(*providerConfig.IAMInstanceProfile.ID),
},
ImageId: aws.String(*providerConfig.AMI.ID),
InstanceType: &providerConfig.InstanceType,
MinCount: aws.Int64(1),
MaxCount: aws.Int64(1),
KeyName: providerConfig.KeyName,
TagSpecifications: []*ec2.TagSpecification{{
ResourceType: aws.String("instance"),
Tags: stubTagList,
}, {
ResourceType: aws.String("volume"),
Tags: stubTagList,
}},
NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{
{
DeviceIndex: aws.Int64(providerConfig.DeviceIndex),
AssociatePublicIpAddress: providerConfig.PublicIP,
SubnetId: providerConfig.Subnet.ID,
Groups: stubSecurityGroupsDefault,
},
},
UserData: aws.String(""),
Placement: &ec2.Placement{
GroupName: aws.String("placement-group1"),
PartitionNumber: aws.Int64(4),
},
},
},
{
name: "Wavelength Zone with Public IP",
providerConfig: stubProviderConfigCustomized(&stubInput{
Expand Down
7 changes: 7 additions & 0 deletions pkg/actuators/machine/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ func stubInstancePlacementGroupName(placementGroupName string) *machinev1beta1.A
return pc
}

func stubInstancePlacementGroupPartition(placementGroupName string, partitionNumber int32) *machinev1beta1.AWSMachineProviderConfig {
pc := stubProviderConfig()
pc.PlacementGroupName = placementGroupName
pc.PlacementGroupPartition = partitionNumber
return pc
}

func stubEFANetworkInterfaceType() *machinev1beta1.AWSMachineProviderConfig {
pc := stubProviderConfig()
pc.NetworkInterfaceType = machinev1beta1.AWSEFANetworkInterfaceType
Expand Down

0 comments on commit 6b515c0

Please sign in to comment.