Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move instance tenancy under placement field #370

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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