Skip to content

Commit 5e44fa5

Browse files
committed
Added the capacity reservation id
Removed the tests by verify-gen
1 parent dc07755 commit 5e44fa5

11 files changed

+40
-36
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
5959
dst.Status.Bastion.PlacementGroupPartition = restored.Status.Bastion.PlacementGroupPartition
6060
dst.Status.Bastion.PrivateDNSName = restored.Status.Bastion.PrivateDNSName
6161
dst.Status.Bastion.PublicIPOnLaunch = restored.Status.Bastion.PublicIPOnLaunch
62+
dst.Status.Bastion.CapacityReservationID = restored.Status.Bastion.CapacityReservationID
6263
}
6364
dst.Spec.Partition = restored.Spec.Partition
6465

api/v1beta1/awsmachine_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
4141
dst.Spec.PlacementGroupPartition = restored.Spec.PlacementGroupPartition
4242
dst.Spec.PrivateDNSName = restored.Spec.PrivateDNSName
4343
dst.Spec.SecurityGroupOverrides = restored.Spec.SecurityGroupOverrides
44+
dst.Spec.CapacityReservationID = restored.Spec.CapacityReservationID
4445
if restored.Spec.ElasticIPPool != nil {
4546
if dst.Spec.ElasticIPPool == nil {
4647
dst.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}
@@ -102,6 +103,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
102103
dst.Spec.Template.Spec.PlacementGroupPartition = restored.Spec.Template.Spec.PlacementGroupPartition
103104
dst.Spec.Template.Spec.PrivateDNSName = restored.Spec.Template.Spec.PrivateDNSName
104105
dst.Spec.Template.Spec.SecurityGroupOverrides = restored.Spec.Template.Spec.SecurityGroupOverrides
106+
dst.Spec.Template.Spec.CapacityReservationID = restored.Spec.Template.Spec.CapacityReservationID
105107
if restored.Spec.Template.Spec.ElasticIPPool != nil {
106108
if dst.Spec.Template.Spec.ElasticIPPool == nil {
107109
dst.Spec.Template.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}

api/v1beta2/awsmachine_types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,9 @@ type AWSMachineSpec struct {
194194
// +optional
195195
PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"`
196196

197-
// CapacityReservationID specifies the instance that should be launched in the
198-
// reserved compute capacity.
197+
// CapacityReservationID specifies the target Capacity Reservation into which the instance should be launched.
199198
// +optional
200-
CapacityReservationID string `json:"capacityReservationId,omitempty"`
199+
CapacityReservationID *string `json:"capacityReservationId,omitempty"`
201200
}
202201

203202
// CloudInit defines options related to the bootstrapping systems where

api/v1beta2/types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,9 @@ type Instance struct {
250250
// +optional
251251
PublicIPOnLaunch *bool `json:"publicIPOnLaunch,omitempty"`
252252

253-
// CapacityReservationID specifies the instance that should be launched in the
254-
// reserved compute capacity.
253+
// CapacityReservationID specifies the target Capacity Reservation into which the instance should be launched.
255254
// +optional
256-
CapacityReservationID string `json:"capacityReservationId,omitempty"`
255+
CapacityReservationID *string `json:"capacityReservationId,omitempty"`
257256
}
258257

259258
// InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,8 @@ spec:
10911091
description: Availability zone of instance
10921092
type: string
10931093
capacityReservationId:
1094-
description: |-
1095-
CapacityReservationID specifies the instance that should be launched in the
1096-
reserved compute capacity.
1094+
description: CapacityReservationID specifies the target Capacity
1095+
Reservation into which the instance should be launched.
10971096
type: string
10981097
ebsOptimized:
10991098
description: Indicates whether the instance is optimized for Amazon
@@ -3100,9 +3099,8 @@ spec:
31003099
description: Availability zone of instance
31013100
type: string
31023101
capacityReservationId:
3103-
description: |-
3104-
CapacityReservationID specifies the instance that should be launched in the
3105-
reserved compute capacity.
3102+
description: CapacityReservationID specifies the target Capacity
3103+
Reservation into which the instance should be launched.
31063104
type: string
31073105
ebsOptimized:
31083106
description: Indicates whether the instance is optimized for Amazon

config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,9 +2076,8 @@ spec:
20762076
description: Availability zone of instance
20772077
type: string
20782078
capacityReservationId:
2079-
description: |-
2080-
CapacityReservationID specifies the instance that should be launched in the
2081-
reserved compute capacity.
2079+
description: CapacityReservationID specifies the target Capacity
2080+
Reservation into which the instance should be launched.
20822081
type: string
20832082
ebsOptimized:
20842083
description: Indicates whether the instance is optimized for Amazon

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,8 @@ spec:
625625
type: string
626626
type: object
627627
capacityReservationId:
628-
description: |-
629-
CapacityReservationID specifies the instance that should be launched in the
630-
reserved compute capacity.
628+
description: CapacityReservationID specifies the target Capacity Reservation
629+
into which the instance should be launched.
631630
type: string
632631
cloudInit:
633632
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,8 @@ spec:
555555
type: string
556556
type: object
557557
capacityReservationId:
558-
description: |-
559-
CapacityReservationID specifies the instance that should be launched in the
560-
reserved compute capacity.
558+
description: CapacityReservationID specifies the target Capacity
559+
Reservation into which the instance should be launched.
561560
type: string
562561
cloudInit:
563562
description: |-

pkg/cloud/services/ec2/instances.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,20 +1122,17 @@ func filterGroups(list []string, strToFilter string) (newList []string) {
11221122
return
11231123
}
11241124

1125-
func getCapacityReservationSpecification(capacityReservationID string) *ec2.CapacityReservationSpecification {
1126-
if capacityReservationID == "" {
1127-
// Instance is not a CapacityReservation instance
1125+
func getCapacityReservationSpecification(capacityReservationID *string) *ec2.CapacityReservationSpecification {
1126+
if capacityReservationID == nil {
1127+
// Not targeting any specific Capacity Reservation
11281128
return nil
11291129
}
11301130

1131-
// Set required values for CapacityReservation
1132-
capacityReservationTargetOptions := &ec2.CapacityReservationTarget{}
1133-
capacityReservationTargetOptions.SetCapacityReservationId(capacityReservationID)
1134-
1135-
capacityReservationSpecification := &ec2.CapacityReservationSpecification{}
1136-
capacityReservationSpecification.SetCapacityReservationTarget(capacityReservationTargetOptions)
1137-
1138-
return capacityReservationSpecification
1131+
return &ec2.CapacityReservationSpecification{
1132+
CapacityReservationTarget: &ec2.CapacityReservationTarget{
1133+
CapacityReservationId: capacityReservationID,
1134+
},
1135+
}
11391136
}
11401137

11411138
func getInstanceMarketOptionsRequest(spotMarketOptions *infrav1.SpotMarketOptions) *ec2.InstanceMarketOptionsRequest {

0 commit comments

Comments
 (0)