From 20c098013f567c4436030e69a9acbb926d4d37b9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 10 Feb 2022 13:20:05 -0600 Subject: [PATCH] fix overhead calculation to correctly apply kube-reserved cpu --- pkg/cloudprovider/aws/instancetype.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/aws/instancetype.go b/pkg/cloudprovider/aws/instancetype.go index 43c615088a68..61cd58a99e21 100644 --- a/pkg/cloudprovider/aws/instancetype.go +++ b/pkg/cloudprovider/aws/instancetype.go @@ -16,6 +16,7 @@ package aws import ( "fmt" + "github.com/aws/amazon-vpc-resource-controller-k8s/pkg/aws/vpc" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" @@ -155,7 +156,9 @@ func (i *InstanceType) Overhead() v1.ResourceList { if cpu < cpuRange.end { r = float64(cpu - cpuRange.start) } - overhead.Cpu().Add(*resource.NewMilliQuantity(int64(r*cpuRange.percentage), resource.DecimalSI)) + cpuOverhead := overhead[v1.ResourceCPU] + cpuOverhead.Add(*resource.NewMilliQuantity(int64(r*cpuRange.percentage), resource.DecimalSI)) + overhead[v1.ResourceCPU] = cpuOverhead } } return overhead