Skip to content

Commit

Permalink
revert EnablePodENI change (for separate PR)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Oct 16, 2023
1 parent 2f7fedf commit 44c877e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
14 changes: 14 additions & 0 deletions pkg/providers/instancetype/nodeclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ var _ = Describe("NodeClass/InstanceTypes", func() {
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
ExpectScheduled(ctx, env.Client, pod)
})
It("should fail to launch AWS Pod ENI if the setting enabling it isn't set", func() {
ctx = settings.ToContext(ctx, test.Settings(test.SettingOptions{
EnablePodENI: lo.ToPtr(false),
}))
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
pod := coretest.UnschedulablePod(coretest.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Requests: v1.ResourceList{v1beta1.ResourceAWSPodENI: resource.MustParse("1")},
Limits: v1.ResourceList{v1beta1.ResourceAWSPodENI: resource.MustParse("1")},
},
})
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
ExpectNotScheduled(ctx, env.Client, pod)
})
It("should launch AWS Pod ENI on a compatible instance type", func() {
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
pod := coretest.UnschedulablePod(coretest.PodOptions{
Expand Down
14 changes: 14 additions & 0 deletions pkg/providers/instancetype/nodetemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,20 @@ var _ = Describe("NodeTemplate/InstanceTypes", func() {
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
ExpectScheduled(ctx, env.Client, pod)
})
It("should fail to launch AWS Pod ENI if the setting enabling it isn't set", func() {
ctx = settings.ToContext(ctx, test.Settings(test.SettingOptions{
EnablePodENI: lo.ToPtr(false),
}))
ExpectApplied(ctx, env.Client, provisioner, nodeTemplate)
pod := coretest.UnschedulablePod(coretest.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Requests: v1.ResourceList{v1alpha1.ResourceAWSPodENI: resource.MustParse("1")},
Limits: v1.ResourceList{v1alpha1.ResourceAWSPodENI: resource.MustParse("1")},
},
})
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
ExpectNotScheduled(ctx, env.Client, pod)
})
It("should launch AWS Pod ENI on a compatible instance type", func() {
ExpectApplied(ctx, env.Client, provisioner, nodeTemplate)
pod := coretest.UnschedulablePod(coretest.PodOptions{
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/instancetype/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func computeCapacity(ctx context.Context, info *ec2.InstanceTypeInfo, amiFamily
v1.ResourceMemory: *memory(ctx, info),
v1.ResourceEphemeralStorage: *ephemeralStorage(amiFamily, blockDeviceMappings),
v1.ResourcePods: *pods(ctx, info, amiFamily, kc),
v1beta1.ResourceAWSPodENI: *awsPodENI(aws.StringValue(info.InstanceType)),
v1beta1.ResourceAWSPodENI: *awsPodENI(ctx, aws.StringValue(info.InstanceType)),
v1beta1.ResourceNVIDIAGPU: *nvidiaGPUs(info),
v1beta1.ResourceAMDGPU: *amdGPUs(info),
v1beta1.ResourceAWSNeuron: *awsNeurons(info),
Expand Down Expand Up @@ -238,10 +238,10 @@ func ephemeralStorage(amiFamily amifamily.AMIFamily, blockDeviceMappings []*v1be
return amifamily.DefaultEBS.VolumeSize
}

func awsPodENI(name string) *resource.Quantity {
func awsPodENI(ctx context.Context, name string) *resource.Quantity {
// https://docs.aws.amazon.com/eks/latest/userguide/security-groups-for-pods.html#supported-instance-types
limits, ok := Limits[name]
if ok && limits.IsTrunkingCompatible {
if settings.FromContext(ctx).EnablePodENI && ok && limits.IsTrunkingCompatible {
return resources.Quantity(fmt.Sprint(limits.BranchInterface))
}
return resources.Quantity("0")
Expand Down

0 comments on commit 44c877e

Please sign in to comment.