From d20fb07dd5ade2f2b8a80fcf36ddf083b71244f2 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Sun, 5 Dec 2021 15:07:01 -0500 Subject: [PATCH] Update tests --- pkg/cloudprovider/aws/fake/ec2api.go | 35 +++++++++++++++++++++++++ pkg/cloudprovider/aws/launchtemplate.go | 2 +- pkg/cloudprovider/aws/suite_test.go | 11 ++++++++ pkg/cloudprovider/fake/cloudprovider.go | 4 +++ pkg/cloudprovider/fake/instancetype.go | 6 +++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/aws/fake/ec2api.go b/pkg/cloudprovider/aws/fake/ec2api.go index 42bea1e3f6e2..17bcb6d98eb4 100644 --- a/pkg/cloudprovider/aws/fake/ec2api.go +++ b/pkg/cloudprovider/aws/fake/ec2api.go @@ -218,12 +218,34 @@ func (e *EC2API) DescribeInstanceTypesPagesWithContext(_ context.Context, _ *ec2 } fn(&ec2.DescribeInstanceTypesOutput{ InstanceTypes: []*ec2.InstanceTypeInfo{ + { + InstanceType: aws.String("t3.large"), + SupportedUsageClasses: DefaultSupportedUsageClasses, + SupportedVirtualizationTypes: []*string{aws.String("hvm")}, + BurstablePerformanceSupported: aws.Bool(true), + BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), + ProcessorInfo: &ec2.ProcessorInfo{ + SupportedArchitectures: aws.StringSlice([]string{"x86_64"}), + }, + VCpuInfo: &ec2.VCpuInfo{ + DefaultVCpus: aws.Int64(2), + }, + MemoryInfo: &ec2.MemoryInfo{ + SizeInMiB: aws.Int64(8 * 1024), + }, + NetworkInfo: &ec2.NetworkInfo{ + MaximumNetworkInterfaces: aws.Int64(3), + Ipv4AddressesPerInterface: aws.Int64(12), + }, + }, { InstanceType: aws.String("m5.large"), SupportedUsageClasses: DefaultSupportedUsageClasses, SupportedVirtualizationTypes: []*string{aws.String("hvm")}, BurstablePerformanceSupported: aws.Bool(false), BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), ProcessorInfo: &ec2.ProcessorInfo{ SupportedArchitectures: aws.StringSlice([]string{"x86_64"}), }, @@ -244,6 +266,7 @@ func (e *EC2API) DescribeInstanceTypesPagesWithContext(_ context.Context, _ *ec2 SupportedVirtualizationTypes: []*string{aws.String("hvm")}, BurstablePerformanceSupported: aws.Bool(false), BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), ProcessorInfo: &ec2.ProcessorInfo{ SupportedArchitectures: aws.StringSlice([]string{"x86_64"}), }, @@ -264,6 +287,7 @@ func (e *EC2API) DescribeInstanceTypesPagesWithContext(_ context.Context, _ *ec2 SupportedVirtualizationTypes: []*string{aws.String("hvm")}, BurstablePerformanceSupported: aws.Bool(false), BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), ProcessorInfo: &ec2.ProcessorInfo{ SupportedArchitectures: aws.StringSlice([]string{"x86_64"}), }, @@ -290,6 +314,7 @@ func (e *EC2API) DescribeInstanceTypesPagesWithContext(_ context.Context, _ *ec2 SupportedVirtualizationTypes: []*string{aws.String("hvm")}, BurstablePerformanceSupported: aws.Bool(false), BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), ProcessorInfo: &ec2.ProcessorInfo{ SupportedArchitectures: aws.StringSlice([]string{v1alpha5.ArchitectureArm64}), }, @@ -310,6 +335,7 @@ func (e *EC2API) DescribeInstanceTypesPagesWithContext(_ context.Context, _ *ec2 SupportedVirtualizationTypes: []*string{aws.String("hvm")}, BurstablePerformanceSupported: aws.Bool(false), BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), ProcessorInfo: &ec2.ProcessorInfo{ SupportedArchitectures: aws.StringSlice([]string{"x86_64"}), }, @@ -335,6 +361,7 @@ func (e *EC2API) DescribeInstanceTypesPagesWithContext(_ context.Context, _ *ec2 SupportedVirtualizationTypes: []*string{aws.String("hvm")}, BurstablePerformanceSupported: aws.Bool(false), BareMetal: aws.Bool(false), + Hypervisor: aws.String("nitro"), ProcessorInfo: &ec2.ProcessorInfo{ SupportedArchitectures: aws.StringSlice([]string{"x86_64"}), }, @@ -402,6 +429,14 @@ func (e *EC2API) DescribeInstanceTypeOfferingsPagesWithContext(_ context.Context InstanceType: aws.String("p3.8xlarge"), Location: aws.String("test-zone-1b"), }, + { + InstanceType: aws.String("t3.large"), + Location: aws.String("test-zone-1a"), + }, + { + InstanceType: aws.String("t3.large"), + Location: aws.String("test-zone-1b"), + }, { InstanceType: aws.String("inf1.2xlarge"), Location: aws.String("test-zone-1a"), diff --git a/pkg/cloudprovider/aws/launchtemplate.go b/pkg/cloudprovider/aws/launchtemplate.go index 130bc6a491f9..33c3fd8f1be2 100644 --- a/pkg/cloudprovider/aws/launchtemplate.go +++ b/pkg/cloudprovider/aws/launchtemplate.go @@ -157,7 +157,7 @@ func (p *LaunchTemplateProvider) ensureLaunchTemplate(ctx context.Context, optio } // needsDocker returns true if the instance type is unable to use -// conatinerd directly +// containerd directly func needsDocker(is []cloudprovider.InstanceType) bool { for _, i := range is { if !i.AWSNeurons().IsZero() || !i.NvidiaGPUs().IsZero() { diff --git a/pkg/cloudprovider/aws/suite_test.go b/pkg/cloudprovider/aws/suite_test.go index 3592894c4a6b..e669dfe0392d 100644 --- a/pkg/cloudprovider/aws/suite_test.go +++ b/pkg/cloudprovider/aws/suite_test.go @@ -121,6 +121,17 @@ var _ = Describe("Allocation", func() { Context("Reconciliation", func() { Context("Specialized Hardware", func() { + It("should not launch AWS Pod ENI on a t3", func() { + for _, pod := range ExpectProvisioned(ctx, env.Client, scheduler, provisioners, provisioner, + test.UnschedulablePod(test.PodOptions{ + NodeSelector: map[string]string{ + v1.LabelInstanceTypeStable: "t3.large", + resources.AWSPodENI: "true", + }, + })) { + ExpectNotScheduled(ctx, env.Client, pod) + } + }) It("should launch instances for Nvidia GPU resource requests", func() { nodeNames := sets.NewString() for _, pod := range ExpectProvisioned(ctx, env.Client, scheduler, provisioners, provisioner, diff --git a/pkg/cloudprovider/fake/cloudprovider.go b/pkg/cloudprovider/fake/cloudprovider.go index b43404c3d111..8a20821eb09a 100644 --- a/pkg/cloudprovider/fake/cloudprovider.go +++ b/pkg/cloudprovider/fake/cloudprovider.go @@ -82,6 +82,10 @@ func (c *CloudProvider) GetInstanceTypes(_ context.Context, _ *v1alpha5.Constrai NewInstanceType(InstanceTypeOptions{ name: "default-instance-type", }), + NewInstanceType(InstanceTypeOptions{ + name: "pod-eni-instance-type", + awsPodENI: true, + }), NewInstanceType(InstanceTypeOptions{ name: "small-instance-type", cpu: resource.MustParse("2"), diff --git a/pkg/cloudprovider/fake/instancetype.go b/pkg/cloudprovider/fake/instancetype.go index 640eedb1e3e4..ba31b8f203ee 100644 --- a/pkg/cloudprovider/fake/instancetype.go +++ b/pkg/cloudprovider/fake/instancetype.go @@ -53,6 +53,7 @@ func NewInstanceType(options InstanceTypeOptions) *InstanceType { nvidiaGPUs: options.nvidiaGPUs, amdGPUs: options.amdGPUs, awsNeurons: options.awsNeurons, + awsPodENI: options.awsPodENI, }, } } @@ -67,6 +68,7 @@ type InstanceTypeOptions struct { nvidiaGPUs resource.Quantity amdGPUs resource.Quantity awsNeurons resource.Quantity + awsPodENI bool } type InstanceType struct { @@ -109,6 +111,10 @@ func (i *InstanceType) AWSNeurons() *resource.Quantity { return &i.awsNeurons } +func (i *InstanceType) AWSPodENI() bool { + return i.awsPodENI +} + func (i *InstanceType) Overhead() v1.ResourceList { return v1.ResourceList{ v1.ResourceCPU: resource.MustParse("100m"),