Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Nov 3, 2022
1 parent 0214d7f commit 2c81fe5
Show file tree
Hide file tree
Showing 11 changed files with 493 additions and 482 deletions.
3 changes: 1 addition & 2 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package main

import (
"github.com/samber/lo"
"k8s.io/utils/clock"

awscloudprovider "github.com/aws/karpenter/pkg/cloudprovider"
"github.com/aws/karpenter/pkg/context"
Expand Down Expand Up @@ -49,7 +48,7 @@ func main() {
operator.
WithControllers(ctx, corecontrollers.NewControllers(
ctx,
clock.RealClock{},
operator.Clock,
operator.GetClient(),
operator.KubernetesInterface,
state.NewCluster(operator.SettingsStore.InjectSettings(ctx), operator.Clock, operator.GetClient(), cloudProvider),
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ var (
LabelInstanceGPUCount = LabelDomain + "/instance-gpu-count"
LabelInstanceGPUMemory = LabelDomain + "/instance-gpu-memory"
LabelInstanceAMIID = LabelDomain + "/instance-ami-id"

InterruptionInfrastructureFinalizer = Group + "/interruption-infrastructure"
)

var (
Expand Down
16 changes: 11 additions & 5 deletions pkg/controllers/interruption/interruption_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
awscontext "github.com/aws/karpenter/pkg/context"
"github.com/aws/karpenter/pkg/controllers/interruption"
"github.com/aws/karpenter/pkg/controllers/interruption/events"
"github.com/aws/karpenter/pkg/controllers/nodetemplate"
"github.com/aws/karpenter/pkg/controllers/providers"
awstest "github.com/aws/karpenter/pkg/test"

Expand Down Expand Up @@ -181,6 +182,7 @@ func benchmarkNotificationController(b *testing.B, messageCount int) {
}

type providerSet struct {
kubeClient client.Client
sqsProvider *providers.SQS
eventBridgeProvider *providers.EventBridge
}
Expand All @@ -192,7 +194,7 @@ func newProviders(ctx context.Context) providerSet {
awsclient.DefaultRetryer{NumMaxRetries: awsclient.DefaultRetryerMaxNumRetries},
),
))
sqsProvider = providers.NewSQS(ctx, sqs.New(sess))
sqsProvider = providers.NewSQS(sqs.New(sess))
eventBridgeProvider = providers.NewEventBridge(eventbridge.New(sess), sqsProvider)
return providerSet{
sqsProvider: sqsProvider,
Expand All @@ -201,10 +203,11 @@ func newProviders(ctx context.Context) providerSet {
}

func (p *providerSet) makeInfrastructure(ctx context.Context) error {
infraProvider := providers.NewInfrastructure(p.sqsProvider, p.eventBridgeProvider)
if err := infraProvider.Create(ctx); err != nil {
infraReconciler := nodetemplate.NewInfrastructureReconciler(p.kubeClient, p.sqsProvider, p.eventBridgeProvider)
if err := infraReconciler.CreateInfrastructure(ctx); err != nil {
return fmt.Errorf("creating infrastructure, %w", err)
}

if err := p.sqsProvider.SetQueueAttributes(ctx, map[string]*string{
sqs.QueueAttributeNameMessageRetentionPeriod: aws.String("1200"), // 20 minutes for this test
}); err != nil {
Expand All @@ -214,8 +217,11 @@ func (p *providerSet) makeInfrastructure(ctx context.Context) error {
}

func (p *providerSet) cleanupInfrastructure(ctx context.Context) error {
infraProvider := providers.NewInfrastructure(p.sqsProvider, p.eventBridgeProvider)
return infraProvider.Delete(ctx)
infraReconciler := nodetemplate.NewInfrastructureReconciler(p.kubeClient, p.sqsProvider, p.eventBridgeProvider)
if err := infraReconciler.DeleteInfrastructure(ctx); err != nil {
return fmt.Errorf("deleting infrastructure, %w", err)
}
return nil
}

func (p *providerSet) provisionMessages(ctx context.Context, messages ...interface{}) error {
Expand Down
Loading

0 comments on commit 2c81fe5

Please sign in to comment.