diff --git a/go.mod b/go.mod index 6b4b72c03..2c288f53b 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index fe7776184..96a954408 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/actuators/machine/instances.go b/pkg/actuators/machine/instances.go index 84c519328..d66e51953 100644 --- a/pkg/actuators/machine/instances.go +++ b/pkg/actuators/machine/instances.go @@ -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 diff --git a/pkg/actuators/machine/instances_test.go b/pkg/actuators/machine/instances_test.go index d45ec317b..cd9e3440a 100644 --- a/pkg/actuators/machine/instances_test.go +++ b/pkg/actuators/machine/instances_test.go @@ -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{ diff --git a/pkg/actuators/machine/stubs.go b/pkg/actuators/machine/stubs.go index f2d8e5448..23c134342 100644 --- a/pkg/actuators/machine/stubs.go +++ b/pkg/actuators/machine/stubs.go @@ -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 diff --git a/vendor/github.com/openshift/api/machine/v1beta1/types_awsprovider.go b/vendor/github.com/openshift/api/machine/v1beta1/types_awsprovider.go index f3853579b..2e3223b10 100644 --- a/vendor/github.com/openshift/api/machine/v1beta1/types_awsprovider.go +++ b/vendor/github.com/openshift/api/machine/v1beta1/types_awsprovider.go @@ -84,6 +84,13 @@ type AWSMachineProviderConfig struct { // When omitted, no placement group is used when creating the EC2 instance. // +optional PlacementGroupName string `json:"placementGroupName,omitempty"` + // placementGroupPartition is the partition number within the placement group in which to launch the instance. + // This must be an integer value between 1 and 7. It is only valid if the placement group, referred in + // `PlacementGroupName` was created with strategy set to partition. + // +kubebuilder:validation:Minimum:=1 + // +kubebuilder:validation:Maximum:=7 + // +optional + PlacementGroupPartition int32 `json:"placementGroupPartition,omitempty"` } // BlockDeviceMappingSpec describes a block device mapping diff --git a/vendor/github.com/openshift/api/machine/v1beta1/zz_generated.swagger_doc_generated.go b/vendor/github.com/openshift/api/machine/v1beta1/zz_generated.swagger_doc_generated.go index 31b6f78d6..f2173537c 100644 --- a/vendor/github.com/openshift/api/machine/v1beta1/zz_generated.swagger_doc_generated.go +++ b/vendor/github.com/openshift/api/machine/v1beta1/zz_generated.swagger_doc_generated.go @@ -12,25 +12,26 @@ package v1beta1 // AUTO-GENERATED FUNCTIONS START HERE var map_AWSMachineProviderConfig = map[string]string{ - "": "AWSMachineProviderConfig is the Schema for the awsmachineproviderconfigs API Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).", - "ami": "AMI is the reference to the AMI from which to create the machine instance.", - "instanceType": "InstanceType is the type of instance to create. Example: m4.xlarge", - "tags": "Tags is the set of tags to add to apply to an instance, in addition to the ones added by default by the actuator. These tags are additive. The actuator will ensure these tags are present, but will not remove any other tags that may exist on the instance.", - "iamInstanceProfile": "IAMInstanceProfile is a reference to an IAM role to assign to the instance", - "userDataSecret": "UserDataSecret contains a local reference to a secret that contains the UserData to apply to the instance", - "credentialsSecret": "CredentialsSecret is a reference to the secret with AWS credentials. Otherwise, defaults to permissions provided by attached IAM role where the actuator is running.", - "keyName": "KeyName is the name of the KeyPair to use for SSH", - "deviceIndex": "DeviceIndex is the index of the device on the instance for the network interface attachment. Defaults to 0.", - "publicIp": "PublicIP specifies whether the instance should get a public IP. If not present, it should use the default of its subnet.", - "networkInterfaceType": "NetworkInterfaceType specifies the type of network interface to be used for the primary network interface. Valid values are \"ENA\", \"EFA\", and omitted, which means no opinion and the platform chooses a good default which may change over time. The current default value is \"ENA\". Please visit https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html to learn more about the AWS Elastic Fabric Adapter interface option.", - "securityGroups": "SecurityGroups is an array of references to security groups that should be applied to the instance.", - "subnet": "Subnet is a reference to the subnet to use for this instance", - "placement": "Placement specifies where to create the instance in AWS", - "loadBalancers": "LoadBalancers is the set of load balancers to which the new instance should be added once it is created.", - "blockDevices": "BlockDevices is the set of block device mapping associated to this instance, block device without a name will be used as a root device and only one device without a name is allowed https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html", - "spotMarketOptions": "SpotMarketOptions allows users to configure instances to be run using AWS Spot instances.", - "metadataServiceOptions": "MetadataServiceOptions allows users to configure instance metadata service interaction options. If nothing specified, default AWS IMDS settings will be applied. https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceMetadataOptionsRequest.html", - "placementGroupName": "PlacementGroupName specifies the name of the placement group in which to launch the instance. The placement group must already be created and may use any placement strategy. When omitted, no placement group is used when creating the EC2 instance.", + "": "AWSMachineProviderConfig is the Schema for the awsmachineproviderconfigs API Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).", + "ami": "AMI is the reference to the AMI from which to create the machine instance.", + "instanceType": "InstanceType is the type of instance to create. Example: m4.xlarge", + "tags": "Tags is the set of tags to add to apply to an instance, in addition to the ones added by default by the actuator. These tags are additive. The actuator will ensure these tags are present, but will not remove any other tags that may exist on the instance.", + "iamInstanceProfile": "IAMInstanceProfile is a reference to an IAM role to assign to the instance", + "userDataSecret": "UserDataSecret contains a local reference to a secret that contains the UserData to apply to the instance", + "credentialsSecret": "CredentialsSecret is a reference to the secret with AWS credentials. Otherwise, defaults to permissions provided by attached IAM role where the actuator is running.", + "keyName": "KeyName is the name of the KeyPair to use for SSH", + "deviceIndex": "DeviceIndex is the index of the device on the instance for the network interface attachment. Defaults to 0.", + "publicIp": "PublicIP specifies whether the instance should get a public IP. If not present, it should use the default of its subnet.", + "networkInterfaceType": "NetworkInterfaceType specifies the type of network interface to be used for the primary network interface. Valid values are \"ENA\", \"EFA\", and omitted, which means no opinion and the platform chooses a good default which may change over time. The current default value is \"ENA\". Please visit https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html to learn more about the AWS Elastic Fabric Adapter interface option.", + "securityGroups": "SecurityGroups is an array of references to security groups that should be applied to the instance.", + "subnet": "Subnet is a reference to the subnet to use for this instance", + "placement": "Placement specifies where to create the instance in AWS", + "loadBalancers": "LoadBalancers is the set of load balancers to which the new instance should be added once it is created.", + "blockDevices": "BlockDevices is the set of block device mapping associated to this instance, block device without a name will be used as a root device and only one device without a name is allowed https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html", + "spotMarketOptions": "SpotMarketOptions allows users to configure instances to be run using AWS Spot instances.", + "metadataServiceOptions": "MetadataServiceOptions allows users to configure instance metadata service interaction options. If nothing specified, default AWS IMDS settings will be applied. https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceMetadataOptionsRequest.html", + "placementGroupName": "PlacementGroupName specifies the name of the placement group in which to launch the instance. The placement group must already be created and may use any placement strategy. When omitted, no placement group is used when creating the EC2 instance.", + "placementGroupPartition": "placementGroupPartition is the partition number within the placement group in which to launch the instance. This must be an integer value between 1 and 7. It is only valid if the placement group, referred in `PlacementGroupName` was created with strategy set to partition.", } func (AWSMachineProviderConfig) SwaggerDoc() map[string]string { diff --git a/vendor/modules.txt b/vendor/modules.txt index bcd18f9b3..32e48b52f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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 @@ -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