Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aws/karpenter-provider-aws
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c63c9e656125ebc3a98929efd2eba7f8f4eb4a9a
Choose a base ref
..
head repository: aws/karpenter-provider-aws
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cda22f97de8e903860321cf82ec9640fb0f3cc90
Choose a head ref
2 changes: 1 addition & 1 deletion .github/actions/e2e/cleanup/action.yaml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ inputs.git_ref }}
- uses: ./.github/actions/e2e/install-eksctl
2 changes: 1 addition & 1 deletion .github/actions/e2e/install-karpenter/action.yaml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ inputs.git_ref }}
- uses: ./.github/actions/e2e/install-helm
2 changes: 1 addition & 1 deletion .github/actions/e2e/install-prometheus/action.yaml
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ inputs.git_ref }}
- uses: ./.github/actions/e2e/install-helm
2 changes: 1 addition & 1 deletion .github/actions/e2e/setup-cluster/action.yaml
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ inputs.git_ref }}
- uses: ./.github/actions/e2e/install-eksctl
2 changes: 1 addition & 1 deletion .github/actions/e2e/slack/notify/action.yaml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ inputs.git_ref }}
- id: get-run-name
2 changes: 1 addition & 1 deletion .github/actions/e2e/upgrade-crds/action.yaml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ runs:
role-to-assume: arn:aws:iam::${{ inputs.account_id }}:role/${{ inputs.role }}
aws-region: ${{ inputs.region }}
role-duration-seconds: 21600
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ inputs.git_ref }}
- name: install-karpenter
3 changes: 0 additions & 3 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
@@ -15,8 +15,6 @@ limitations under the License.
package main

import (
"github.com/samber/lo"

"github.com/aws/karpenter-provider-aws/pkg/cloudprovider"
"github.com/aws/karpenter-provider-aws/pkg/controllers"
"github.com/aws/karpenter-provider-aws/pkg/operator"
@@ -37,7 +35,6 @@ func main() {
op.AMIProvider,
op.SecurityGroupProvider,
)
lo.Must0(op.AddHealthzCheck("cloud-provider", awsCloudProvider.LivenessProbe))
cloudProvider := metrics.Decorate(awsCloudProvider)

op.
18 changes: 10 additions & 8 deletions hack/docs/instancetypes_gen/main.go
Original file line number Diff line number Diff line change
@@ -129,16 +129,18 @@ below are the resources available with some assumptions and after the instance o
ec2api := ec2.New(sess)
subnetProvider := subnet.NewDefaultProvider(ec2api, cache.New(awscache.DefaultTTL, awscache.DefaultCleanupInterval), cache.New(awscache.AvailableIPAddressTTL, awscache.DefaultCleanupInterval), cache.New(awscache.AssociatePublicIPAddressTTL, awscache.DefaultCleanupInterval))
instanceTypeProvider := instancetype.NewDefaultProvider(
region,
cache.New(awscache.InstanceTypesAndZonesTTL, awscache.DefaultCleanupInterval),
ec2api,
subnetProvider,
awscache.NewUnavailableOfferings(),
pricing.NewDefaultProvider(
ctx,
pricing.NewAPI(sess, *sess.Config.Region),
ec2api,
*sess.Config.Region,
instancetype.NewDefaultResolver(
region,
pricing.NewDefaultProvider(
ctx,
pricing.NewAPI(sess, *sess.Config.Region),
ec2api,
*sess.Config.Region,
),
awscache.NewUnavailableOfferings(),
),
)
if err = instanceTypeProvider.UpdateInstanceTypes(ctx); err != nil {
@@ -172,7 +174,7 @@ below are the resources available with some assumptions and after the instance o
Zone: *ec2subnet.AvailabilityZone,
}
})
instanceTypes, err := instanceTypeProvider.List(ctx, &v1.KubeletConfiguration{}, nodeClass)
instanceTypes, err := instanceTypeProvider.List(ctx, nodeClass)
if err != nil {
log.Fatalf("listing instance types, %s", err)
}
9 changes: 2 additions & 7 deletions pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import (
"context"
stderrors "errors"
"fmt"
"net/http"
"time"

"github.com/aws/aws-sdk-go/service/ec2"
@@ -159,10 +158,6 @@ func (c *CloudProvider) Get(ctx context.Context, providerID string) (*karpv1.Nod
return c.instanceToNodeClaim(instance, instanceType, nc), nil
}

func (c *CloudProvider) LivenessProbe(req *http.Request) error {
return c.instanceTypeProvider.LivenessProbe(req)
}

// GetInstanceTypes returns all available InstanceTypes
func (c *CloudProvider) GetInstanceTypes(ctx context.Context, nodePool *karpv1.NodePool) ([]*cloudprovider.InstanceType, error) {
nodeClass, err := c.resolveNodeClassFromNodePool(ctx, nodePool)
@@ -176,7 +171,7 @@ func (c *CloudProvider) GetInstanceTypes(ctx context.Context, nodePool *karpv1.N
return nil, fmt.Errorf("resolving node class, %w", err)
}
// TODO, break this coupling
instanceTypes, err := c.instanceTypeProvider.List(ctx, nodeClass.Spec.Kubelet, nodeClass)
instanceTypes, err := c.instanceTypeProvider.List(ctx, nodeClass)
if err != nil {
return nil, err
}
@@ -260,7 +255,7 @@ func (c *CloudProvider) resolveNodeClassFromNodePool(ctx context.Context, nodePo
}

func (c *CloudProvider) resolveInstanceTypes(ctx context.Context, nodeClaim *karpv1.NodeClaim, nodeClass *v1.EC2NodeClass) ([]*cloudprovider.InstanceType, error) {
instanceTypes, err := c.instanceTypeProvider.List(ctx, nodeClass.Spec.Kubelet, nodeClass)
instanceTypes, err := c.instanceTypeProvider.List(ctx, nodeClass)
if err != nil {
return nil, fmt.Errorf("getting instance types, %w", err)
}
6 changes: 3 additions & 3 deletions pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package controllers

import (
"context"
"github.com/aws/karpenter-provider-aws/pkg/controllers/providers/instancetype/memoryoverhead"

"github.com/awslabs/operatorpkg/controller"
"github.com/awslabs/operatorpkg/status"
@@ -27,7 +28,6 @@ import (
nodeclassstatus "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/status"
nodeclasstermination "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/termination"
controllersinstancetype "github.com/aws/karpenter-provider-aws/pkg/controllers/providers/instancetype"
"github.com/aws/karpenter-provider-aws/pkg/controllers/providers/instancetype/memoryoverhead"
controllerspricing "github.com/aws/karpenter-provider-aws/pkg/controllers/providers/pricing"
"github.com/aws/karpenter-provider-aws/pkg/providers/launchtemplate"

@@ -57,7 +57,7 @@ import (
func NewControllers(ctx context.Context, mgr manager.Manager, sess *session.Session, clk clock.Clock, kubeClient client.Client, recorder events.Recorder,
unavailableOfferings *cache.UnavailableOfferings, cloudProvider cloudprovider.CloudProvider, subnetProvider subnet.Provider,
securityGroupProvider securitygroup.Provider, instanceProfileProvider instanceprofile.Provider, instanceProvider instance.Provider,
pricingProvider pricing.Provider, amiProvider amifamily.Provider, launchTemplateProvider launchtemplate.Provider, instanceTypeProvider instancetype.Provider) []controller.Controller {
pricingProvider pricing.Provider, amiProvider amifamily.Provider, launchTemplateProvider launchtemplate.Provider, instanceTypeProvider *instancetype.DefaultProvider) []controller.Controller {

controllers := []controller.Controller{
nodeclasshash.NewController(kubeClient),
@@ -67,8 +67,8 @@ func NewControllers(ctx context.Context, mgr manager.Manager, sess *session.Sess
nodeclaimtagging.NewController(kubeClient, instanceProvider),
controllerspricing.NewController(pricingProvider),
controllersinstancetype.NewController(instanceTypeProvider),
memoryoverhead.NewController(kubeClient, instanceTypeProvider),
status.NewController[*v1.EC2NodeClass](kubeClient, mgr.GetEventRecorderFor("karpenter")),
memoryoverhead.NewController(kubeClient, instanceTypeProvider),
}
if options.FromContext(ctx).InterruptionQueue != "" {
sqsapi := servicesqs.New(sess)
10 changes: 5 additions & 5 deletions pkg/controllers/providers/instancetype/controller.go
Original file line number Diff line number Diff line change
@@ -31,21 +31,21 @@ import (
)

type Controller struct {
instancetypeProvider instancetype.Provider
instanceTypeProvider *instancetype.DefaultProvider
}

func NewController(instancetypeProvider instancetype.Provider) *Controller {
func NewController(instanceTypeProvider *instancetype.DefaultProvider) *Controller {
return &Controller{
instancetypeProvider: instancetypeProvider,
instanceTypeProvider: instanceTypeProvider,
}
}

func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {
ctx = injection.WithControllerName(ctx, "providers.instancetype")

work := []func(ctx context.Context) error{
c.instancetypeProvider.UpdateInstanceTypes,
c.instancetypeProvider.UpdateInstanceTypeOfferings,
c.instanceTypeProvider.UpdateInstanceTypes,
c.instanceTypeProvider.UpdateInstanceTypeOfferings,
}
errs := make([]error, len(work))
lop.ForEach(work, func(f func(ctx context.Context) error, i int) {
Original file line number Diff line number Diff line change
@@ -34,10 +34,10 @@ import (

type Controller struct {
kubeClient client.Client
instancetypeProvider instancetype.Provider
instancetypeProvider *instancetype.DefaultProvider
}

func NewController(kubeClient client.Client, instancetypeProvider instancetype.Provider) *Controller {
func NewController(kubeClient client.Client, instancetypeProvider *instancetype.DefaultProvider) *Controller {
return &Controller{
kubeClient: kubeClient,
instancetypeProvider: instancetypeProvider,
8 changes: 4 additions & 4 deletions pkg/controllers/providers/instancetype/suite_test.go
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ var _ = Describe("InstanceType", func() {
})

ExpectSingletonReconciled(ctx, controller)
instanceTypes, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.KubeletConfiguration{}, &v1.EC2NodeClass{
instanceTypes, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.EC2NodeClass{
Status: v1.EC2NodeClassStatus{
Subnets: []v1.Subnet{
{
@@ -123,7 +123,7 @@ var _ = Describe("InstanceType", func() {
})

ExpectSingletonReconciled(ctx, controller)
instanceTypes, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.KubeletConfiguration{}, &v1.EC2NodeClass{
instanceTypes, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.EC2NodeClass{
Status: v1.EC2NodeClassStatus{
Subnets: []v1.Subnet{
{
@@ -158,14 +158,14 @@ var _ = Describe("InstanceType", func() {
awsEnv.EC2API.DescribeInstanceTypesOutput.Set(&ec2.DescribeInstanceTypesOutput{})
awsEnv.EC2API.DescribeInstanceTypeOfferingsOutput.Set(&ec2.DescribeInstanceTypeOfferingsOutput{})
ExpectSingletonReconciled(ctx, controller)
_, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.KubeletConfiguration{}, &v1.EC2NodeClass{})
_, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.EC2NodeClass{})
Expect(err).ToNot(BeNil())
})
It("should not update instance type offering date with response from the DescribeInstanceTypesOfferings API", func() {
awsEnv.EC2API.DescribeInstanceTypesOutput.Set(&ec2.DescribeInstanceTypesOutput{})
awsEnv.EC2API.DescribeInstanceTypeOfferingsOutput.Set(&ec2.DescribeInstanceTypeOfferingsOutput{})
ExpectSingletonReconciled(ctx, controller)
_, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.KubeletConfiguration{}, &v1.EC2NodeClass{})
_, err := awsEnv.InstanceTypesProvider.List(ctx, &v1.EC2NodeClass{})
Expect(err).ToNot(BeNil())
})
})
6 changes: 2 additions & 4 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ type Operator struct {
LaunchTemplateProvider launchtemplate.Provider
PricingProvider pricing.Provider
VersionProvider version.Provider
InstanceTypesProvider instancetype.Provider
InstanceTypesProvider *instancetype.DefaultProvider
InstanceProvider instance.Provider
SSMProvider ssmp.Provider
}
@@ -158,13 +158,11 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont
clusterEndpoint,
)
instanceTypeProvider := instancetype.NewDefaultProvider(
*sess.Config.Region,
cache.New(awscache.InstanceTypesAndZonesTTL, awscache.DefaultCleanupInterval),
cache.New(awscache.VMMemoryOverheadMebibytesTTL, awscache.DefaultCleanupInterval),
ec2api,
subnetProvider,
unavailableOfferingsCache,
pricingProvider,
instancetype.NewDefaultResolver(*sess.Config.Region, pricingProvider, unavailableOfferingsCache),
)
instanceProvider := instance.NewDefaultProvider(
ctx,
Loading