Skip to content

Commit

Permalink
Move instance tenancy under placement field
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Demichev committed Nov 11, 2020
1 parent bc5addc commit 461dacf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/actuators/machine/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func launchInstance(machine *machinev1.Machine, machineProviderConfig *awsprovid
}
}

instanceTenancy := machineProviderConfig.Tenancy
instanceTenancy := machineProviderConfig.Placement.Tenancy

switch instanceTenancy {
case "":
Expand All @@ -351,7 +351,7 @@ func launchInstance(machine *machinev1.Machine, machineProviderConfig *awsprovid
if placement == nil {
placement = &ec2.Placement{}
}
tenancy := string(machineProviderConfig.Tenancy)
tenancy := string(instanceTenancy)
placement.Tenancy = &tenancy
default:
return nil, mapierrors.CreateMachine("invalid instance tenancy: %s. Allowed options are: %s,%s,%s",
Expand Down
4 changes: 2 additions & 2 deletions pkg/actuators/machine/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ func stubPCAMI(ami awsproviderv1.AWSResourceReference) *awsproviderv1.AWSMachine

func stubDedicatedInstanceTenancy() *awsproviderv1.AWSMachineProviderConfig {
pc := stubProviderConfig()
pc.Tenancy = awsproviderv1.DedicatedTenancy
pc.Placement.Tenancy = awsproviderv1.DedicatedTenancy
return pc
}

func stubInvalidInstanceTenancy() *awsproviderv1.AWSMachineProviderConfig {
pc := stubProviderConfig()
pc.Tenancy = "invalid"
pc.Placement.Tenancy = "invalid"
return pc
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/awsprovider/v1beta1/awsproviderconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ type AWSMachineProviderConfig struct {

// SpotMarketOptions allows users to configure instances to be run using AWS Spot instances.
SpotMarketOptions *SpotMarketOptions `json:"spotMarketOptions,omitempty"`

// Tenancy indicates if instance should run on shared or single-tenant hardware. There are
// supported 3 options: default, dedicated and host.
Tenancy InstanceTenancy `json:"tenancy,omitempty"`
}

// BlockDeviceMappingSpec describes a block device mapping
Expand Down Expand Up @@ -200,6 +196,10 @@ type Placement struct {

// AvailabilityZone is the availability zone of the instance
AvailabilityZone string `json:"availabilityZone,omitempty"`

// Tenancy indicates if instance should run on shared or single-tenant hardware. There are
// supported 3 options: default, dedicated and host.
Tenancy InstanceTenancy `json:"tenancy,omitempty"`
}

// Filter is a filter used to identify an AWS resource
Expand Down

0 comments on commit 461dacf

Please sign in to comment.