Skip to content

Commit

Permalink
Setting static value for ephemeral-storage on aws instance-types (#1567)
Browse files Browse the repository at this point in the history
  • Loading branch information
dewjam authored Mar 23, 2022
1 parent 850d51e commit 4eabb05
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
13 changes: 7 additions & 6 deletions pkg/cloudprovider/aws/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@ func (p *InstanceProvider) instanceToNode(ctx context.Context, instance *ec2.Ins

resources := v1.ResourceList{}
for resourceName, quantity := range map[v1.ResourceName]resource.Quantity{
v1.ResourcePods: instanceType.Resources()[v1.ResourcePods],
v1.ResourceCPU: instanceType.Resources()[v1.ResourceCPU],
v1.ResourceMemory: instanceType.Resources()[v1.ResourceMemory],
v1alpha1.ResourceNVIDIAGPU: instanceType.Resources()[v1alpha1.ResourceNVIDIAGPU],
v1alpha1.ResourceAMDGPU: instanceType.Resources()[v1alpha1.ResourceAMDGPU],
v1alpha1.ResourceAWSNeuron: instanceType.Resources()[v1alpha1.ResourceAWSNeuron],
v1.ResourcePods: instanceType.Resources()[v1.ResourcePods],
v1.ResourceCPU: instanceType.Resources()[v1.ResourceCPU],
v1.ResourceMemory: instanceType.Resources()[v1.ResourceMemory],
v1.ResourceEphemeralStorage: instanceType.Resources()[v1.ResourceEphemeralStorage],
v1alpha1.ResourceNVIDIAGPU: instanceType.Resources()[v1alpha1.ResourceNVIDIAGPU],
v1alpha1.ResourceAMDGPU: instanceType.Resources()[v1alpha1.ResourceAMDGPU],
v1alpha1.ResourceAWSNeuron: instanceType.Resources()[v1alpha1.ResourceAWSNeuron],
} {
if !quantity.IsZero() {
resources[resourceName] = quantity
Expand Down
20 changes: 13 additions & 7 deletions pkg/cloudprovider/aws/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ func (i *InstanceType) Architecture() string {

func (i *InstanceType) Resources() v1.ResourceList {
return v1.ResourceList{
v1.ResourceCPU: i.cpu(),
v1.ResourceMemory: i.memory(),
v1.ResourcePods: i.pods(),
v1alpha1.ResourceAWSPodENI: i.awsPodENI(),
v1alpha1.ResourceNVIDIAGPU: i.nvidiaGPUs(),
v1alpha1.ResourceAMDGPU: i.amdGPUs(),
v1alpha1.ResourceAWSNeuron: i.awsNeurons(),
v1.ResourceCPU: i.cpu(),
v1.ResourceMemory: i.memory(),
v1.ResourceEphemeralStorage: i.ephemeralStorage(),
v1.ResourcePods: i.pods(),
v1alpha1.ResourceAWSPodENI: i.awsPodENI(),
v1alpha1.ResourceNVIDIAGPU: i.nvidiaGPUs(),
v1alpha1.ResourceAMDGPU: i.amdGPUs(),
v1alpha1.ResourceAWSNeuron: i.awsNeurons(),
}
}

Expand Down Expand Up @@ -114,6 +115,11 @@ func (i *InstanceType) memory() resource.Quantity {
)
}

// Setting ephemeral-storage to be arbitrarily large so it will be ignored during binpacking
func (i *InstanceType) ephemeralStorage() resource.Quantity {
return resource.MustParse("100Pi")
}

func (i *InstanceType) pods() resource.Quantity {
if i.MaxPods != nil {
return *resources.Quantity(fmt.Sprint(ptr.Int32Value(i.MaxPods)))
Expand Down
30 changes: 30 additions & 0 deletions pkg/cloudprovider/aws/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,36 @@ var _ = Describe("Allocation", func() {
Expect(input.LaunchTemplateData.BlockDeviceMappings[1].Ebs.Iops).To(BeNil())
})
})
Context("Ephemeral Storage", func() {
It("should pack pods when a daemonset has an ephemeral-storage request", func() {
ExpectCreated(ctx, env.Client, test.DaemonSet(
test.DaemonSetOptions{PodOptions: test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"),
v1.ResourceMemory: resource.MustParse("1Gi"),
v1.ResourceEphemeralStorage: resource.MustParse("1Gi")}},
}},
))
pod := ExpectProvisioned(ctx, env.Client, selectionController, provisioners, provisioner, test.UnschedulablePod())
ExpectScheduled(ctx, env.Client, pod[0])
})
It("should pack pods with any ephemeral-storage request", func() {
pod := ExpectProvisioned(ctx, env.Client, selectionController, provisioners, provisioner,
test.UnschedulablePod(test.PodOptions{ResourceRequirements: v1.ResourceRequirements{
Requests: map[v1.ResourceName]resource.Quantity{
v1.ResourceEphemeralStorage: resource.MustParse("1G"),
}}}))
ExpectScheduled(ctx, env.Client, pod[0])
})
It("should pack pods with large ephemeral-storage request", func() {
pod := ExpectProvisioned(ctx, env.Client, selectionController, provisioners, provisioner,
test.UnschedulablePod(test.PodOptions{ResourceRequirements: v1.ResourceRequirements{
Requests: map[v1.ResourceName]resource.Quantity{
v1.ResourceEphemeralStorage: resource.MustParse("1Pi"),
}}}))
ExpectScheduled(ctx, env.Client, pod[0])
})
})
})
Context("Defaulting", func() {
// Intent here is that if updates occur on the controller, the Provisioner doesn't need to be recreated
Expand Down

0 comments on commit 4eabb05

Please sign in to comment.