Skip to content

Commit 5834d9a

Browse files
rvanderp3jimzim
andcommitted
add support for dynamic dedicated host allocation
Co-authored-by: Jim Zimmerman <[email protected]>
1 parent 55b4aca commit 5834d9a

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

api/v1beta2/awsmachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ const (
4747
type DynamicHostReleaseStrategy string
4848

4949
const (
50-
// DedicatedHostReleaseStrategyOnMachineDeletion means the dedicated host will be released when the machine is deleted.
50+
// DedicatedHostReleaseStrategyOnMachineDeletion specifies the strategy to release the Dedicated Host instance when the machine is deleted.
5151
DedicatedHostReleaseStrategyOnMachineDeletion = DynamicHostReleaseStrategy("on-machine-deletion")
5252

53-
// DedicatedHostReleaseStrategyManual means the dedicated host will be released manually by the user.
53+
// DedicatedHostReleaseStrategyManual specifies the strategy to release the Dedicated Host instance manually by the user.
5454
DedicatedHostReleaseStrategyManual = DynamicHostReleaseStrategy("manual")
5555
)
5656

pkg/cloud/services/ec2/dedicatedhosts.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ import (
3535
// This function always allocates exactly one dedicated host per call.
3636
func (s *Service) AllocateDedicatedHost(ctx context.Context, spec *infrav1.DynamicHostAllocationSpec, instanceType, availabilityZone string) (string, error) {
3737
s.scope.Debug("Allocating single dedicated host", "instanceType", instanceType, "availabilityZone", availabilityZone)
38-
instanceFamily := extractInstanceFamily(instanceType)
3938
input := &ec2.AllocateHostsInput{
40-
InstanceFamily: aws.String(instanceFamily),
39+
InstanceType: aws.String(instanceType),
4140
AvailabilityZone: aws.String(availabilityZone),
4241
Quantity: aws.Int32(1), // Always allocate exactly one host
4342
}
@@ -118,7 +117,7 @@ func (s *Service) DescribeDedicatedHost(ctx context.Context, hostID string) (*in
118117
return hostInfo, nil
119118
}
120119

121-
// convertToHostInfo converts an AWS Host to our DedicatedHostInfo struct.
120+
// convertToHostInfo converts an AWS Host to the DedicatedHostInfo struct.
122121
func (s *Service) convertToHostInfo(host types.Host) *infrav1.DedicatedHostInfo {
123122
hostInfo := &infrav1.DedicatedHostInfo{
124123
HostID: aws.ToString(host.HostId),

pkg/cloud/services/ec2/instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ func (s *Service) allocateHostIfNeeded(ctx context.Context, scope *scope.Machine
12981298

12991299
// Check if a host is already allocated for this machine
13001300
if scope.AWSMachine.Status.AllocatedHostID != nil {
1301-
existingHostID := *scope.AWSMachine.Status.AllocatedHostID
1301+
existingHostID := aws.StringValue(scope.AWSMachine.Status.AllocatedHostID)
13021302
s.scope.Info("Found existing allocated host for machine", "hostID", existingHostID, "machine", scope.Name())
13031303

13041304
// Validate that the existing host is still available and compatible

0 commit comments

Comments
 (0)