Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
Signed-off-by: Mahmoud Gaballah <mahmoud.gaballah@zalando.de>
  • Loading branch information
myaser committed Feb 6, 2024
1 parent 9909fc2 commit 7cd6667
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 6 additions & 14 deletions pkg/updatestrategy/aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"strings"
"time"

Expand Down Expand Up @@ -138,7 +139,7 @@ func (n *EC2NodePoolBackend) filterWithNodePool(nodePool *api.NodePool) []*ec2.F
},
},
{
Name: aws.String("tag:" + nodePoolTag), // TODO: this needs to be conditional
Name: aws.String("tag:" + nodePoolTag),
Values: []*string{
aws.String(nodePool.Name),
},
Expand Down Expand Up @@ -305,15 +306,6 @@ func (r *KarpenterCRDNameResolver) NodeTemplateCRDName() string {
}
}

func (r *KarpenterCRDNameResolver) referenceFieldName() string {
switch r.NodePoolCRDName {
case karpenterNodePoolResource:
return "nodeClassRef"
default:
return "providerRef"
}
}

func (r *KarpenterCRDNameResolver) getAMIsFromSpec(spec interface{}) string {
switch r.NodePoolCRDName {
case karpenterNodePoolResource:
Expand Down Expand Up @@ -342,10 +334,10 @@ func (r *KarpenterCRDNameResolver) getInstanceTag() string {
func (r *KarpenterCRDNameResolver) NodePoolConfigGetter(ctx context.Context, nodePool *api.NodePool) (*InstanceConfig, error) {
// CLM assumes that the node pool name is used for both the node-pool and the node-template that it references
NodeTemplate, err := r.k8sClients.Get(ctx, r.NodeTemplateCRDName(), "", nodePool.Name, v1.GetOptions{})
//if apierrors.IsNotFound(err) {
// // the node pool have been deleted. thus the
// return nil, nil
//}
if apierrors.IsNotFound(err) {
// the node pool have been deleted. thus returning nil nodePoolConfig will result in labeling all nodes for decommission
return nil, nil
}
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion provisioner/clusterpy.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ func (p *clusterpyProvisioner) prepareProvision(logger *log.Entry, cluster *api.
if err != nil {
return nil, nil, err
}
// TODO: lazy init, better error handling for the resolver and use a universal karpenter tag for decommission 'karpenter.sh/managed-by'

additionalBackends := map[string]updatestrategy.ProviderNodePoolsBackend{
karpenterNodePoolProfile: updatestrategy.NewEC2NodePoolBackend(cluster.ID, adapter.session, func() (*updatestrategy.KarpenterCRDNameResolver, error) {
return updatestrategy.NewKarpenterCRDResolver(context.Background(), k8sClients)
Expand Down

0 comments on commit 7cd6667

Please sign in to comment.