diff --git a/go.mod b/go.mod index 35d61c32b8c8..122082f0081c 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( sigs.k8s.io/controller-runtime v0.16.2 ) -replace github.com/aws/karpenter-core => github.com/jonathan-innis/karpenter-core v0.0.0-20231012191332-1e368cfd9c25 +replace github.com/aws/karpenter-core => github.com/jonathan-innis/karpenter-core v0.0.0-20231012194850-a87f5352a4a2 require ( contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect diff --git a/go.sum b/go.sum index 515cc37ce939..0a2662576a34 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y 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= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jonathan-innis/karpenter-core v0.0.0-20231012191332-1e368cfd9c25 h1:ouaAwe6U5+LIgvgnAfwa7gMnFKtpvgrRMc6ATJlCiP4= -github.com/jonathan-innis/karpenter-core v0.0.0-20231012191332-1e368cfd9c25/go.mod h1:rb3kp/3cj38tACF6udfpmIvKoQMwirSVoHNlrd66LyE= +github.com/jonathan-innis/karpenter-core v0.0.0-20231012194850-a87f5352a4a2 h1:xK10aTyO3FKOZ4yxk/z7p8U+QeQecH9xxsh4kyyS+K0= +github.com/jonathan-innis/karpenter-core v0.0.0-20231012194850-a87f5352a4a2/go.mod h1:rb3kp/3cj38tACF6udfpmIvKoQMwirSVoHNlrd66LyE= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= diff --git a/hack/docs/configuration_gen_docs.go b/hack/docs/configuration_gen_docs.go index 65556ace64a4..cd8c197dc854 100644 --- a/hack/docs/configuration_gen_docs.go +++ b/hack/docs/configuration_gen_docs.go @@ -52,7 +52,7 @@ func main() { envVarsBlock := "| Environment Variable | CLI Flag | Description |\n" envVarsBlock += "|--|--|--|\n" - opts.VisitAll(func(f *flag.Flag) { + opts.FlagSet.VisitAll(func(f *flag.Flag) { if f.DefValue == "" { envVarsBlock += fmt.Sprintf("| %s | %s | %s|\n", strings.ReplaceAll(strings.ToUpper(f.Name), "-", "_"), "\\-\\-"+f.Name, f.Usage) } else { diff --git a/pkg/controllers/nodeclass/controller.go b/pkg/controllers/nodeclass/controller.go index 314f492fdb77..22eaa711d9a6 100644 --- a/pkg/controllers/nodeclass/controller.go +++ b/pkg/controllers/nodeclass/controller.go @@ -104,7 +104,7 @@ func (c *Controller) Finalize(ctx context.Context, nodeClass *v1beta1.EC2NodeCla return reconcile.Result{}, nil } nodeClaimList := &corev1beta1.NodeClaimList{} - if err := c.kubeClient.List(ctx, nodeClaimList, client.MatchingFields{"spec.nodeClass.name": nodeClass.Name}); err != nil { + if err := c.kubeClient.List(ctx, nodeClaimList, client.MatchingFields{"spec.nodeClassRef.name": nodeClass.Name}); err != nil { return reconcile.Result{}, fmt.Errorf("listing nodeclaims that are using nodeclass, %w", err) } if len(nodeClaimList.Items) > 0 { diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index d07f0dd98f7a..3e430aafa32c 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -37,6 +37,7 @@ import ( "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/ssm" "github.com/patrickmn/go-cache" + "sigs.k8s.io/controller-runtime/pkg/client" "github.com/samber/lo" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -46,6 +47,7 @@ import ( "knative.dev/pkg/logging" "knative.dev/pkg/ptr" + corev1beta1 "github.com/aws/karpenter-core/pkg/apis/v1beta1" "github.com/aws/karpenter-core/pkg/operator" "github.com/aws/karpenter/pkg/apis/settings" awscache "github.com/aws/karpenter/pkg/cache" @@ -167,6 +169,14 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont launchTemplateProvider, ) + lo.Must0(operator.Manager.GetFieldIndexer().IndexField(ctx, &corev1beta1.NodeClaim{}, "spec.nodeClassRef.name", func(o client.Object) []string { + nc := o.(*corev1beta1.NodeClaim) + if nc.Spec.NodeClassRef == nil { + return []string{} + } + return []string{nc.Spec.NodeClassRef.Name} + }), "failed to setup nodeclaim indexer") + return ctx, &Operator{ Operator: operator, Session: sess,