Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Convert singleton reconcilers to operatorpkg #6310

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/karpenter-provider-aws

go 1.22.3
go 1.22.4

require (
github.com/Pallinder/go-randomdata v1.2.0
Expand All @@ -9,7 +9,7 @@ require (
github.com/aws/aws-sdk-go v1.53.14
github.com/aws/karpenter-provider-aws/tools/kompat v0.0.0-20240410220356-6b868db24881
github.com/awslabs/amazon-eks-ami/nodeadm v0.0.0-20240229193347-cfab22a10647
github.com/awslabs/operatorpkg v0.0.0-20240518001059-1e35978ba21b
github.com/awslabs/operatorpkg v0.0.0-20240605172541-88cf99023fa4
github.com/go-logr/zapr v1.3.0
github.com/imdario/mergo v0.3.16
github.com/mitchellh/hashstructure/v2 v2.0.2
Expand All @@ -30,7 +30,7 @@ require (
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
knative.dev/pkg v0.0.0-20231010144348-ca8c009405dd
sigs.k8s.io/controller-runtime v0.18.3
sigs.k8s.io/karpenter v0.37.0
sigs.k8s.io/karpenter v0.37.1-0.20240605225346-c7c5068db687
sigs.k8s.io/yaml v1.4.0
)

Expand All @@ -51,7 +51,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
Expand Down Expand Up @@ -113,6 +113,7 @@ require (
k8s.io/component-base v0.30.1 // indirect
k8s.io/csi-translation-lib v0.30.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubernetes v1.30.1 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ github.com/aws/karpenter-provider-aws/tools/kompat v0.0.0-20240410220356-6b868db
github.com/aws/karpenter-provider-aws/tools/kompat v0.0.0-20240410220356-6b868db24881/go.mod h1:+Mk5k0b6HpKobxNq+B56DOhZ+I/NiPhd5MIBhQMSTSs=
github.com/awslabs/amazon-eks-ami/nodeadm v0.0.0-20240229193347-cfab22a10647 h1:8yRBVsjGmI7qQsPWtIrbWP+XfwHO9Wq7gdLVzjqiZFs=
github.com/awslabs/amazon-eks-ami/nodeadm v0.0.0-20240229193347-cfab22a10647/go.mod h1:9NafTAUHL0FlMeL6Cu5PXnMZ1q/LnC9X2emLXHsVbM8=
github.com/awslabs/operatorpkg v0.0.0-20240518001059-1e35978ba21b h1:bmlbw6EjSDoZEWbGE2rnXDsCgbTsxMyufM4NRRHaLVk=
github.com/awslabs/operatorpkg v0.0.0-20240518001059-1e35978ba21b/go.mod h1:YcidmUg8Pjk349+jd+sRCdo6h3jzxqAY1VDNgVJKbSA=
github.com/awslabs/operatorpkg v0.0.0-20240605172541-88cf99023fa4 h1:EVFVrteX0PQuofO9Ah4rf4aGyUkBM3lLuKgzwilAEAg=
github.com/awslabs/operatorpkg v0.0.0-20240605172541-88cf99023fa4/go.mod h1:OR0NDOTl6XUXKgcksUab5d7mCnpaZf7Ko4eWEbheJTY=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -115,8 +115,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
Expand Down Expand Up @@ -750,6 +750,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/kubernetes v1.30.1 h1:XlqS6KslLEA5mQzLK2AJrhr4Z1m8oJfkhHiWJ5lue+I=
k8s.io/kubernetes v1.30.1/go.mod h1:yPbIk3MhmhGigX62FLJm+CphNtjxqCvAIFQXup6RKS0=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/pkg v0.0.0-20231010144348-ca8c009405dd h1:KJXBX9dOmRTUWduHg1gnWtPGIEl+GMh8UHdrBEZgOXE=
Expand All @@ -761,8 +763,8 @@ sigs.k8s.io/controller-runtime v0.18.3 h1:B5Wmmo8WMWK7izei+2LlXLVDGzMwAHBNLX68lw
sigs.k8s.io/controller-runtime v0.18.3/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/karpenter v0.37.0 h1:eUFD9hJ2mpZrw31OUYhpbxLWEDmbXT05wX27dZB2E5o=
sigs.k8s.io/karpenter v0.37.0/go.mod h1:5XYrIz9Bi7HgQyaUsx7O08ft+TJjrH+htlnPq8Sz9J8=
sigs.k8s.io/karpenter v0.37.1-0.20240605225346-c7c5068db687 h1:I4JBstyyyAwKDXJsb86HAQRPvR2VowsqF81F734L2G8=
sigs.k8s.io/karpenter v0.37.1-0.20240605225346-c7c5068db687/go.mod h1:SO2WU8Li+bwkLiiEYrRmuhP0QUseZCyYgo6OoXgd9uk=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
4 changes: 1 addition & 3 deletions hack/code/prices_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"github.com/aws/aws-sdk-go/aws/session"
ec22 "github.com/aws/aws-sdk-go/service/ec2"
"github.com/samber/lo"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

controllerspricing "github.com/aws/karpenter-provider-aws/pkg/controllers/providers/pricing"
"github.com/aws/karpenter-provider-aws/pkg/operator/options"
Expand Down Expand Up @@ -110,7 +108,7 @@ func main() {
log.Println("fetching for", region)
pricingProvider := pricing.NewDefaultProvider(ctx, pricing.NewAPI(sess, region), ec2, region)
controller := controllerspricing.NewController(pricingProvider)
_, err := controller.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{}})
_, err := controller.Reconcile(ctx)
if err != nil {
log.Fatalf("failed to initialize pricing provider %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package controllers
import (
"context"

"github.com/awslabs/operatorpkg/controller"
"sigs.k8s.io/karpenter/pkg/cloudprovider"
"sigs.k8s.io/karpenter/pkg/operator/controller"

nodeclasshash "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/hash"
nodeclassstatus "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/status"
Expand Down
16 changes: 10 additions & 6 deletions pkg/controllers/interruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ import (
"time"

sqsapi "github.com/aws/aws-sdk-go/service/sqs"
"github.com/awslabs/operatorpkg/singleton"
"github.com/prometheus/client_golang/prometheus"
"github.com/samber/lo"
"go.uber.org/multierr"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"k8s.io/utils/clock"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/karpenter/pkg/metrics"
"sigs.k8s.io/karpenter/pkg/operator/injection"

"sigs.k8s.io/karpenter/pkg/apis/v1beta1"
"sigs.k8s.io/karpenter/pkg/utils/pretty"
Expand All @@ -44,7 +47,6 @@ import (
"github.com/aws/karpenter-provider-aws/pkg/utils"

"sigs.k8s.io/karpenter/pkg/events"
corecontroller "sigs.k8s.io/karpenter/pkg/operator/controller"
)

type Action string
Expand Down Expand Up @@ -81,7 +83,8 @@ func NewController(kubeClient client.Client, clk clock.Clock, recorder events.Re
}
}

func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error) {
func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {
ctx = injection.WithControllerName(ctx, "interruption")
ctx = log.IntoContext(ctx, log.FromContext(ctx).WithValues("queue", c.sqsProvider.Name()))
if c.cm.HasChanged(c.sqsProvider.Name(), nil) {
log.FromContext(ctx).V(1).Info("watching interruption queue")
Expand All @@ -91,7 +94,7 @@ func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconc
return reconcile.Result{}, fmt.Errorf("getting messages from queue, %w", err)
}
if len(sqsMessages) == 0 {
return reconcile.Result{}, nil
return reconcile.Result{RequeueAfter: singleton.RequeueImmediately}, nil
}
nodeClaimInstanceIDMap, err := c.makeNodeClaimInstanceIDMap(ctx)
if err != nil {
Expand Down Expand Up @@ -119,13 +122,14 @@ func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconc
if err = multierr.Combine(errs...); err != nil {
return reconcile.Result{}, err
}
return reconcile.Result{}, nil
return reconcile.Result{RequeueAfter: singleton.RequeueImmediately}, nil
}

func (c *Controller) Register(_ context.Context, m manager.Manager) error {
return corecontroller.NewSingletonManagedBy(m).
return controllerruntime.NewControllerManagedBy(m).
Named("interruption").
Complete(c)
WatchesRawSource(singleton.Source()).
Complete(singleton.AsReconciler(c))
}

// parseMessage parses the passed SQS message into an internal Message interface
Expand Down
21 changes: 10 additions & 11 deletions pkg/controllers/interruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/samber/lo"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/client-go/tools/record"
clock "k8s.io/utils/clock/testing"
Expand Down Expand Up @@ -119,7 +118,7 @@ var _ = Describe("InterruptionHandling", func() {
ExpectMessagesCreated(spotInterruptionMessage(lo.Must(utils.ParseInstanceID(nodeClaim.Status.ProviderID))))
ExpectApplied(ctx, env.Client, nodeClaim, node)

ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
ExpectNotFound(ctx, env.Client, nodeClaim)
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(1))
Expand All @@ -128,7 +127,7 @@ var _ = Describe("InterruptionHandling", func() {
ExpectMessagesCreated(scheduledChangeMessage(lo.Must(utils.ParseInstanceID(nodeClaim.Status.ProviderID))))
ExpectApplied(ctx, env.Client, nodeClaim, node)

ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
ExpectNotFound(ctx, env.Client, nodeClaim)
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(1))
Expand All @@ -153,7 +152,7 @@ var _ = Describe("InterruptionHandling", func() {
messages = append(messages, stateChangeMessage(instanceID, state))
}
ExpectMessagesCreated(messages...)
ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
ExpectNotFound(ctx, env.Client, lo.Map(nodeClaims, func(nc *corev1beta1.NodeClaim, _ int) client.Object { return nc })...)
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(4))
Expand Down Expand Up @@ -183,7 +182,7 @@ var _ = Describe("InterruptionHandling", func() {
messages = append(messages, spotInterruptionMessage(id))
}
ExpectMessagesCreated(messages...)
ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
ExpectNotFound(ctx, env.Client, lo.Map(nodeClaims, func(nc *corev1beta1.NodeClaim, _ int) client.Object { return nc })...)
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(100))
Expand All @@ -199,15 +198,15 @@ var _ = Describe("InterruptionHandling", func() {

ExpectMessagesCreated(badMessage)

ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(1))
})
It("should delete a state change message when the state isn't in accepted states", func() {
ExpectMessagesCreated(stateChangeMessage(lo.Must(utils.ParseInstanceID(nodeClaim.Status.ProviderID)), "creating"))
ExpectApplied(ctx, env.Client, nodeClaim, node)

ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
ExpectExists(ctx, env.Client, nodeClaim)
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(1))
Expand All @@ -221,7 +220,7 @@ var _ = Describe("InterruptionHandling", func() {
ExpectMessagesCreated(spotInterruptionMessage(lo.Must(utils.ParseInstanceID(nodeClaim.Status.ProviderID))))
ExpectApplied(ctx, env.Client, nodeClaim, node)

ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
Expect(sqsapi.ReceiveMessageBehavior.SuccessfulCalls()).To(Equal(1))
ExpectNotFound(ctx, env.Client, nodeClaim)
Expect(sqsapi.DeleteMessageBehavior.SuccessfulCalls()).To(Equal(1))
Expand All @@ -235,15 +234,15 @@ var _ = Describe("InterruptionHandling", func() {
var _ = Describe("Error Handling", func() {
It("should send an error on polling when QueueNotExists", func() {
sqsapi.ReceiveMessageBehavior.Error.Set(awsErrWithCode(servicesqs.ErrCodeQueueDoesNotExist), fake.MaxCalls(0))
ExpectReconcileFailed(ctx, controller, types.NamespacedName{})
_ = ExpectSingletonReconcileFailed(ctx, controller)
})
It("should send an error on polling when AccessDenied", func() {
sqsapi.ReceiveMessageBehavior.Error.Set(awsErrWithCode("AccessDenied"), fake.MaxCalls(0))
ExpectReconcileFailed(ctx, controller, types.NamespacedName{})
_ = ExpectSingletonReconcileFailed(ctx, controller)
})
It("should not return an error when deleting a nodeClaim that is already deleted", func() {
ExpectMessagesCreated(spotInterruptionMessage(fake.InstanceID()))
ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
ExpectSingletonReconciled(ctx, controller)
})
})

Expand Down
13 changes: 9 additions & 4 deletions pkg/controllers/nodeclaim/garbagecollection/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ import (
"fmt"
"time"

"github.com/awslabs/operatorpkg/singleton"
"github.com/samber/lo"
"go.uber.org/multierr"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/karpenter/pkg/cloudprovider"
"sigs.k8s.io/karpenter/pkg/operator/injection"

"sigs.k8s.io/karpenter/pkg/apis/v1beta1"
"sigs.k8s.io/karpenter/pkg/operator/controller"
)

type Controller struct {
Expand All @@ -49,7 +51,9 @@ func NewController(kubeClient client.Client, cloudProvider cloudprovider.CloudPr
}
}

func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error) {
func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {
ctx = injection.WithControllerName(ctx, "nodeclaim.garbagecollection")

// We LIST machines on the CloudProvider BEFORE we grab Machines/Nodes on the cluster so that we make sure that, if
// LISTing instances takes a long time, our information is more updated by the time we get to Machine and Node LIST
// This works since our CloudProvider instances are deleted based on whether the Machine exists or not, not vise-versa
Expand Down Expand Up @@ -105,7 +109,8 @@ func (c *Controller) garbageCollect(ctx context.Context, nodeClaim *v1beta1.Node
}

func (c *Controller) Register(_ context.Context, m manager.Manager) error {
return controller.NewSingletonManagedBy(m).
return controllerruntime.NewControllerManagedBy(m).
Named("nodeclaim.garbagecollection").
Complete(c)
WatchesRawSource(singleton.Source()).
Complete(singleton.AsReconciler(c))
}
Loading
Loading