@@ -52,10 +52,6 @@ import (
5252 terminationutil "sigs.k8s.io/karpenter/pkg/utils/termination"
5353)
5454
55- type nodeClaimReconciler interface {
56- Reconcile (context.Context , * v1.NodeClaim ) (reconcile.Result , error )
57- }
58-
5955// Controller is a NodeClaim Lifecycle controller that manages the lifecycle of the NodeClaim up until its termination
6056// The controller is responsible for ensuring that new Nodes get launched, that they have properly registered with
6157// the cluster as nodes and that they are properly initialized, ensuring that nodeclaims that do not have matching nodes
@@ -108,9 +104,15 @@ func (c *Controller) Name() string {
108104 return "nodeclaim.lifecycle"
109105}
110106
107+ // nolint:gocyclo
111108func (c * Controller ) Reconcile (ctx context.Context , nodeClaim * v1.NodeClaim ) (reconcile.Result , error ) {
112109 ctx = injection .WithControllerName (ctx , c .Name ())
113-
110+ if nodeClaim .Status .ProviderID != "" {
111+ ctx = log .IntoContext (ctx , log .FromContext (ctx ).WithValues ("provider-id" , nodeClaim .Status .ProviderID ))
112+ }
113+ if nodeClaim .Status .NodeName != "" {
114+ ctx = log .IntoContext (ctx , log .FromContext (ctx ).WithValues ("Node" , klog .KRef ("" , nodeClaim .Status .NodeName )))
115+ }
114116 if ! nodeclaimutils .IsManaged (nodeClaim , c .cloudProvider ) {
115117 return reconcile.Result {}, nil
116118 }
@@ -137,7 +139,7 @@ func (c *Controller) Reconcile(ctx context.Context, nodeClaim *v1.NodeClaim) (re
137139 stored = nodeClaim .DeepCopy ()
138140 var results []reconcile.Result
139141 var errs error
140- for _ , reconciler := range []nodeClaimReconciler {
142+ for _ , reconciler := range []reconcile. TypedReconciler [ * v1. NodeClaim ] {
141143 c .launch ,
142144 c .registration ,
143145 c .initialization ,
@@ -169,7 +171,6 @@ func (c *Controller) Reconcile(ctx context.Context, nodeClaim *v1.NodeClaim) (re
169171
170172//nolint:gocyclo
171173func (c * Controller ) finalize (ctx context.Context , nodeClaim * v1.NodeClaim ) (reconcile.Result , error ) {
172- ctx = log .IntoContext (ctx , log .FromContext (ctx ).WithValues ("Node" , klog .KRef ("" , nodeClaim .Status .NodeName ), "provider-id" , nodeClaim .Status .ProviderID ))
173174 if ! controllerutil .ContainsFinalizer (nodeClaim , v1 .TerminationFinalizer ) {
174175 return reconcile.Result {}, nil
175176 }
0 commit comments