Skip to content

Commit

Permalink
adding a special instance-types string 'not-specified
Browse files Browse the repository at this point in the history
Signed-off-by: Mahmoud Gaballah <[email protected]>
  • Loading branch information
myaser committed Dec 2, 2024
1 parent 0a7121e commit 6497dd9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion api/node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (np NodePool) KarpenterRequirements() []v1.NodeSelectorRequirementApplyConf
}

func (np NodePool) KarpenterInstanceTypeStrategy() string {
if len(np.InstanceTypes) == 0 {
if len(np.InstanceTypes) == 1 && np.InstanceTypes[0] == "not-specified" {
return "not-specified"
}
if len(np.InstanceTypes) == 1 && np.InstanceTypes[0] == "default-for-karpenter" {
Expand Down
7 changes: 0 additions & 7 deletions pkg/aws/instance_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@ func getCompatibleCPUArchitecture(instanceType *ec2.InstanceTypeInfo) (string, e
return "", fmt.Errorf("didn't find compatible cpu architecture within '%v'", supportedArchitectures)
}

func min(a int64, b int64) int64 {
if a < b {
return a
}
return b
}

func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
Expand Down
8 changes: 4 additions & 4 deletions pkg/updatestrategy/aws_asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ func (n *ASGNodePoolsBackend) Scale(_ context.Context, nodePool *api.NodePool, r
}

for _, asg := range asgs {
min := int64(math.Min(float64(aws.Int64Value(asg.DesiredCapacity)), float64(aws.Int64Value(asg.MinSize))))
max := int64(math.Max(float64(aws.Int64Value(asg.DesiredCapacity)), float64(aws.Int64Value(asg.MaxSize))))
minSize := int64(math.Min(float64(aws.Int64Value(asg.DesiredCapacity)), float64(aws.Int64Value(asg.MinSize))))
maxSize := int64(math.Max(float64(aws.Int64Value(asg.DesiredCapacity)), float64(aws.Int64Value(asg.MaxSize))))

params := &autoscaling.UpdateAutoScalingGroupInput{
AutoScalingGroupName: asg.AutoScalingGroupName,
DesiredCapacity: asg.DesiredCapacity,
MinSize: aws.Int64(min),
MaxSize: aws.Int64(max),
MinSize: aws.Int64(minSize),
MaxSize: aws.Int64(maxSize),
}

_, err := n.asgClient.UpdateAutoScalingGroup(params)
Expand Down
6 changes: 3 additions & 3 deletions pkg/updatestrategy/rolling_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ func getFailureDomain(nodes []*Node) string {
}
}

min := len(nodes)
minNodes := len(nodes)
failureDomain := "a"
for fd, num := range fdCount {
if num < min || (num == min && fd < failureDomain) {
min = num
if num < minNodes || (num == minNodes && fd < failureDomain) {
minNodes = num
failureDomain = fd
}
}
Expand Down

0 comments on commit 6497dd9

Please sign in to comment.