Skip to content

Commit

Permalink
upstream feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Nov 23, 2024
1 parent fce7b76 commit df37b7b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace sigs.k8s.io/karpenter => github.com/jmdeal/karpenter v0.0.0-20241122235854-ad7c521abeab
replace sigs.k8s.io/karpenter => github.com/jmdeal/karpenter v0.0.0-20241123233936-540eb38f3518
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmdeal/karpenter v0.0.0-20241122235854-ad7c521abeab h1:YTHtCKNjvEVmHhzQSHnkxrX6Mkxx65wi7W6mhoau4Ds=
github.com/jmdeal/karpenter v0.0.0-20241122235854-ad7c521abeab/go.mod h1:zolnK/3MxqSPEhEan2VBbzuGdReJPFTbpYWGivwTgic=
github.com/jmdeal/karpenter v0.0.0-20241123233936-540eb38f3518 h1:kt3dXKB7oIPiz1R/kQDHkj0Frh0pc7Fq8NimyS+eE3s=
github.com/jmdeal/karpenter v0.0.0-20241123233936-540eb38f3518/go.mod h1:zolnK/3MxqSPEhEan2VBbzuGdReJPFTbpYWGivwTgic=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/interruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"sigs.k8s.io/karpenter/pkg/operator/injection"

karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
"sigs.k8s.io/karpenter/pkg/utils/nodeclaim"
nodeclaimutils "sigs.k8s.io/karpenter/pkg/utils/nodeclaim"
"sigs.k8s.io/karpenter/pkg/utils/pretty"

"github.com/aws/karpenter-provider-aws/pkg/cache"
Expand Down Expand Up @@ -258,7 +258,7 @@ func (c *Controller) notifyForMessage(msg messages.Message, nodeClaim *karpv1.No
// NodeClaim .status.providerID and the NodeClaim
func (c *Controller) makeNodeClaimInstanceIDMap(ctx context.Context) (map[string]*karpv1.NodeClaim, error) {
m := map[string]*karpv1.NodeClaim{}
nodeClaims, err := nodeclaim.List(ctx, c.kubeClient, nodeclaim.WithManagedFilter(c.cloudProvider))
nodeClaims, err := nodeclaimutils.ListManaged(ctx, c.kubeClient, c.cloudProvider)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/garbagecollection/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {
cloudNodeClaims = lo.Filter(cloudNodeClaims, func(nc *karpv1.NodeClaim, _ int) bool {
return nc.DeletionTimestamp.IsZero()
})
clusterNodeClaims, err := nodeclaimutils.List(ctx, c.kubeClient, nodeclaimutils.WithManagedFilter(c.cloudProvider))
clusterNodeClaims, err := nodeclaimutils.ListManaged(ctx, c.kubeClient, c.cloudProvider)
if err != nil {
return reconcile.Result{}, err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/controllers/nodeclass/hash/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ func (c *Controller) Register(_ context.Context, m manager.Manager) error {
// EC2NodeClass. Since, we cannot rely on the `ec2nodeclass-hash` on the NodeClaims, due to the breaking change, we will need to re-calculate the hash and update the annotation.
// For more information on the Drift Hash Versioning: https://github.com/kubernetes-sigs/karpenter/blob/main/designs/drift-hash-versioning.md
func (c *Controller) updateNodeClaimHash(ctx context.Context, nodeClass *v1.EC2NodeClass) error {
nodeClaims, err := nodeclaimutils.List(ctx, c.kubeClient, nodeclaimutils.WithNodeClassFilter(nodeClass))
if err != nil {
nodeClaims := &karpv1.NodeClaimList{}
if err := c.kubeClient.List(ctx, nodeClaims, nodeclaimutils.ForNodeClass(nodeClass)); err != nil {
return err
}

errs := make([]error, len(nodeClaims))
for i, nc := range nodeClaims {
errs := make([]error, len(nodeClaims.Items))
for i := range nodeClaims.Items {
nc := &nodeClaims.Items[i]
stored := nc.DeepCopy()

if nc.Annotations[v1.AnnotationEC2NodeClassHashVersion] != v1.EC2NodeClassHashVersion {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/nodeclass/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ func (c *Controller) finalize(ctx context.Context, nodeClass *v1.EC2NodeClass) (
if !controllerutil.ContainsFinalizer(nodeClass, v1.TerminationFinalizer) {
return reconcile.Result{}, nil
}
nodeClaims, err := nodeclaimutils.List(ctx, c.kubeClient, nodeclaimutils.WithNodeClassFilter(nodeClass))
if err != nil {
nodeClaims := &karpv1.NodeClaimList{}
if err := c.kubeClient.List(ctx, nodeClaims, nodeclaimutils.ForNodeClass(nodeClass)); err != nil {
return reconcile.Result{}, fmt.Errorf("listing nodeclaims that are using nodeclass, %w", err)
}
if len(nodeClaims) > 0 {
c.recorder.Publish(WaitingOnNodeClaimTerminationEvent(nodeClass, lo.Map(nodeClaims, func(nc *karpv1.NodeClaim, _ int) string { return nc.Name })))
if len(nodeClaims.Items) > 0 {
c.recorder.Publish(WaitingOnNodeClaimTerminationEvent(nodeClass, lo.Map(nodeClaims.Items, func(nc karpv1.NodeClaim, _ int) string { return nc.Name })))
return reconcile.Result{RequeueAfter: time.Minute * 10}, nil // periodically fire the event
}
if nodeClass.Spec.Role != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c *Controller) Register(_ context.Context, m manager.Manager) error {
},
DeleteFunc: func(e event.TypedDeleteEvent[client.Object]) bool { return false },
GenericFunc: func(e event.TypedGenericEvent[client.Object]) bool { return false },
}, nodeutils.IsManagedPredicates(c.cloudProvider))).
}, nodeutils.IsManagedPredicateFuncs(c.cloudProvider))).
WithOptions(controller.Options{
RateLimiter: reasonable.RateLimiter(),
MaxConcurrentReconciles: 1,
Expand Down

0 comments on commit df37b7b

Please sign in to comment.