diff --git a/go.mod b/go.mod index a67e1b67bcc5..e8483eb9f590 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b knative.dev/pkg v0.0.0-20231010144348-ca8c009405dd sigs.k8s.io/controller-runtime v0.16.3 - sigs.k8s.io/karpenter v0.33.1-0.20231224205745-0b25de76d2ad + sigs.k8s.io/karpenter v0.33.1-0.20231227175620-ea2e47b9fe73 ) require ( diff --git a/go.sum b/go.sum index 31b7a4f42be9..dc76bfb6f0eb 100644 --- a/go.sum +++ b/go.sum @@ -763,8 +763,8 @@ sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigw sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= 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.33.1-0.20231224205745-0b25de76d2ad h1:C3zHs4PswQC3tCtQBFI2hXSj9SEfJNQ5Jcs8giTec8c= -sigs.k8s.io/karpenter v0.33.1-0.20231224205745-0b25de76d2ad/go.mod h1:k1819wVloDPI/TUTEYWII7LgbC6paTSIgYgbywM0r/k= +sigs.k8s.io/karpenter v0.33.1-0.20231227175620-ea2e47b9fe73 h1:L8McmDRGqisYDX5wIG42hVTIgCz7aUdCbN0enVCovRs= +sigs.k8s.io/karpenter v0.33.1-0.20231227175620-ea2e47b9fe73/go.mod h1:OAiiFe16SakE7GJNTuC2YTWZq0rwRUgqkunY1Y9TqYY= 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.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/pkg/controllers/interruption/controller.go b/pkg/controllers/interruption/controller.go index f1e9ba9b5596..e2f3cfc4798e 100644 --- a/pkg/controllers/interruption/controller.go +++ b/pkg/controllers/interruption/controller.go @@ -20,6 +20,7 @@ import ( "time" sqsapi "github.com/aws/aws-sdk-go/service/sqs" + "github.com/prometheus/client_golang/prometheus" "github.com/samber/lo" "go.uber.org/multierr" v1 "k8s.io/api/core/v1" @@ -29,6 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "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/apis/v1beta1" "sigs.k8s.io/karpenter/pkg/utils/pretty" @@ -42,7 +44,6 @@ import ( "sigs.k8s.io/karpenter/pkg/events" corecontroller "sigs.k8s.io/karpenter/pkg/operator/controller" - nodeclaimutil "sigs.k8s.io/karpenter/pkg/utils/nodeclaim" ) type Action string @@ -208,12 +209,15 @@ func (c *Controller) deleteNodeClaim(ctx context.Context, nodeClaim *v1beta1.Nod if !nodeClaim.DeletionTimestamp.IsZero() { return nil } - if err := nodeclaimutil.Delete(ctx, c.kubeClient, nodeClaim); err != nil { + if err := c.kubeClient.Delete(ctx, nodeClaim); err != nil { return client.IgnoreNotFound(fmt.Errorf("deleting the node on interruption message, %w", err)) } logging.FromContext(ctx).Infof("initiating delete from interruption message") c.recorder.Publish(interruptionevents.TerminatingOnInterruption(node, nodeClaim)...) - nodeclaimutil.TerminatedCounter(nodeClaim, terminationReasonLabel).Inc() + metrics.NodeClaimsTerminatedCounter.With(prometheus.Labels{ + metrics.ReasonLabel: terminationReasonLabel, + metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey], + }).Inc() return nil } @@ -245,8 +249,8 @@ func (c *Controller) notifyForMessage(msg messages.Message, nodeClaim *v1beta1.N // NodeClaim .status.providerID and the NodeClaim func (c *Controller) makeNodeClaimInstanceIDMap(ctx context.Context) (map[string]*v1beta1.NodeClaim, error) { m := map[string]*v1beta1.NodeClaim{} - nodeClaimList, err := nodeclaimutil.List(ctx, c.kubeClient) - if err != nil { + nodeClaimList := &v1beta1.NodeClaimList{} + if err := c.kubeClient.List(ctx, nodeClaimList); err != nil { return nil, err } for i := range nodeClaimList.Items { diff --git a/pkg/controllers/nodeclaim/garbagecollection/controller.go b/pkg/controllers/nodeclaim/garbagecollection/controller.go index 6955d23a0392..6e06163bb28b 100644 --- a/pkg/controllers/nodeclaim/garbagecollection/controller.go +++ b/pkg/controllers/nodeclaim/garbagecollection/controller.go @@ -32,7 +32,6 @@ import ( "sigs.k8s.io/karpenter/pkg/apis/v1beta1" corecloudprovider "sigs.k8s.io/karpenter/pkg/cloudprovider" "sigs.k8s.io/karpenter/pkg/operator/controller" - nodeclaimutil "sigs.k8s.io/karpenter/pkg/utils/nodeclaim" "github.com/aws/karpenter-provider-aws/pkg/cloudprovider" ) @@ -66,12 +65,12 @@ func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconc managedRetrieved := lo.Filter(retrieved, func(nc *v1beta1.NodeClaim, _ int) bool { return nc.Annotations[v1beta1.ManagedByAnnotationKey] != "" && nc.DeletionTimestamp.IsZero() }) - nodeClaimList, err := nodeclaimutil.List(ctx, c.kubeClient) - if err != nil { + nodeClaimList := &v1beta1.NodeClaimList{} + if err = c.kubeClient.List(ctx, nodeClaimList); err != nil { return reconcile.Result{}, err } nodeList := &v1.NodeList{} - if err := c.kubeClient.List(ctx, nodeList); err != nil { + if err = c.kubeClient.List(ctx, nodeList); err != nil { return reconcile.Result{}, err } resolvedProviderIDs := sets.New[string](lo.FilterMap(nodeClaimList.Items, func(n v1beta1.NodeClaim, _ int) (string, bool) {