Skip to content

Commit

Permalink
Add truncating back to cloudprovider, considering minValues
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed May 16, 2024
1 parent 7d20e8d commit ed63f4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/providers/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"knative.dev/pkg/logging"

corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1"
"sigs.k8s.io/karpenter/pkg/utils/resources"

Expand All @@ -49,9 +48,12 @@ import (
"sigs.k8s.io/karpenter/pkg/scheduling"
)

var (
const (
instanceTypeFlexibilityThreshold = 5 // falling back to on-demand without flexibility risks insufficient capacity errors
maxInstanceTypes = 60
)

var (
instanceStateFilter = &ec2.Filter{
Name: aws.String("instance-state-name"),
Values: aws.StringSlice([]string{ec2.InstanceStateNamePending, ec2.InstanceStateNameRunning, ec2.InstanceStateNameStopping, ec2.InstanceStateNameStopped, ec2.InstanceStateNameShuttingDown}),
Expand Down Expand Up @@ -95,6 +97,10 @@ func (p *DefaultProvider) Create(ctx context.Context, nodeClass *v1beta1.EC2Node
if !schedulingRequirements.HasMinValues() {
instanceTypes = p.filterInstanceTypes(nodeClaim, instanceTypes)
}
instanceTypes, err := cloudprovider.InstanceTypes(instanceTypes).Truncate(schedulingRequirements, maxInstanceTypes)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / Analyze Go

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.23.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate) (typecheck)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)) (typecheck)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)) (typecheck)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)) (typecheck)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.24.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.25.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.26.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.27.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.28.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)

Check failure on line 100 in pkg/providers/instance/instance.go

View workflow job for this annotation

GitHub Actions / ci-test (1.29.x)

cloudprovider.InstanceTypes(instanceTypes).Truncate undefined (type cloudprovider.InstanceTypes has no field or method Truncate)
if err != nil {
return nil, fmt.Errorf("truncating instance types, %w", err)
}
tags := getTags(ctx, nodeClass, nodeClaim)
fleetInstance, err := p.launchInstance(ctx, nodeClass, nodeClaim, instanceTypes, tags)
if awserrors.IsLaunchTemplateNotFound(err) {
Expand Down

0 comments on commit ed63f4d

Please sign in to comment.