Skip to content

Commit

Permalink
Merge pull request #101 from chiragkyal/partition-number
Browse files Browse the repository at this point in the history
CFE-1064: Add support for PlacementGroupPartition of placement group
  • Loading branch information
openshift-merge-bot[bot] authored Jun 26, 2024
2 parents a97f8aa + 4491fd5 commit 9bbaca9
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 29 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/openshift/machine-api-provider-aws

go 1.22
go 1.22.0

toolchain go1.22.1
toolchain go1.22.4

require (
github.com/aws/aws-sdk-go v1.50.0
Expand All @@ -11,8 +11,8 @@ require (
github.com/golang/mock v1.6.0
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
github.com/openshift/api v0.0.0-20240610131338-a837bee24500
github.com/openshift/machine-api-operator v0.2.1-0.20240606171151-148e5dc759a6
github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0
github.com/openshift/machine-api-operator v0.2.1-0.20240626144425-456f6512c008
k8s.io/api v0.30.1
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg=
github.com/openshift/api v0.0.0-20240610131338-a837bee24500 h1:LHpSWs+zfkvf+hppDWKsKnB5cbzLbUa3MEX0/qtnvAQ=
github.com/openshift/api v0.0.0-20240610131338-a837bee24500/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0 h1:Kn16YZDBGwetg+pMQ0u0/3aOxRXQJi/1lu6rIlK+1So=
github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
github.com/openshift/client-go v0.0.0-20240528061634-b054aa794d87 h1:JtLhaGpSEconE+1IKmIgCOof/Len5ceG6H1pk43yv5U=
github.com/openshift/client-go v0.0.0-20240528061634-b054aa794d87/go.mod h1:3IPD4U0qyovZS4EFady2kqY32m8lGcbs/Wx+yprg9z8=
github.com/openshift/library-go v0.0.0-20240116081341-964bcb3f545c h1:gLylEQQryG+A6nqWYIwE1wUzn1eFUmthjADvflMWKnM=
github.com/openshift/library-go v0.0.0-20240116081341-964bcb3f545c/go.mod h1:82B0gt8XawdXWRtKMrm3jSMTeRsiOSYKCi4F0fvPjG0=
github.com/openshift/machine-api-operator v0.2.1-0.20240606171151-148e5dc759a6 h1:6vLe4UmLrTqPlQGa1Twh/6a72CUjtURighALQ2CBKE0=
github.com/openshift/machine-api-operator v0.2.1-0.20240606171151-148e5dc759a6/go.mod h1:1wkCDl8IVwAsen4F5xvM9uvOXj7yhfQ6BzzEVAVTXsA=
github.com/openshift/machine-api-operator v0.2.1-0.20240626144425-456f6512c008 h1:xPMInfdxraL8lEb1yYjTDZXzONfgcquQpVx/MjPly1M=
github.com/openshift/machine-api-operator v0.2.1-0.20240626144425-456f6512c008/go.mod h1:0hQJFbHS+qy1WY1/lmQpb1tizytRws+IJxGwbtHBqt4=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
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

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

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

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ github.com/onsi/gomega/matchers/support/goraph/edge
github.com/onsi/gomega/matchers/support/goraph/node
github.com/onsi/gomega/matchers/support/goraph/util
github.com/onsi/gomega/types
# github.com/openshift/api v0.0.0-20240610131338-a837bee24500
# github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0
## explicit; go 1.22.0
github.com/openshift/api/config/v1
github.com/openshift/api/config/v1/zz_generated.crd-manifests
Expand Down Expand Up @@ -293,7 +293,7 @@ github.com/openshift/client-go/machine/listers/machine/v1beta1
## explicit; go 1.21
github.com/openshift/library-go/pkg/config/clusterstatus
github.com/openshift/library-go/pkg/config/leaderelection
# github.com/openshift/machine-api-operator v0.2.1-0.20240606171151-148e5dc759a6
# github.com/openshift/machine-api-operator v0.2.1-0.20240626144425-456f6512c008
## explicit; go 1.22.0
github.com/openshift/machine-api-operator/pkg/controller/machine
github.com/openshift/machine-api-operator/pkg/metrics
Expand Down

0 comments on commit 9bbaca9

Please sign in to comment.