@@ -100,24 +100,27 @@ func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {
100
100
}
101
101
return expiringCRs .Has (id )
102
102
})
103
- errs := map [ * karpv1. NodeClaim ]error {}
103
+ errs := make ([ ]error , len ( toDelete ))
104
104
workqueue .ParallelizeUntil (ctx , 10 , len (toDelete ), func (i int ) {
105
105
if err := c .kubeClient .Delete (ctx , toDelete [i ]); err != nil {
106
106
if apierrors .IsNotFound (err ) {
107
107
return
108
108
}
109
- errs [ncs [ i ] ] = err
109
+ errs [i ] = err
110
110
return
111
111
}
112
112
log .FromContext (ctx ).
113
- WithValues ("NodeClaim" , klog .KObj (ncs [i ]), "capacity-reservation-id" , toDelete [i ].Labels [v1 .LabelCapacityReservationID ]).
113
+ WithValues ("NodeClaim" , klog .KObj (toDelete [i ]), "capacity-reservation-id" , toDelete [i ].Labels [v1 .LabelCapacityReservationID ]).
114
114
Info ("initiating delete for capacity block expiration" )
115
115
})
116
116
if len (errs ) != 0 {
117
117
return reconcile.Result {}, serrors .Wrap (
118
- fmt .Errorf ("deleting nodeclaims, %w" , multierr .Combine (lo .Values (errs )... )),
119
- "NodeClaims" , lo .Map (lo .Keys (errs ), func (nc * karpv1.NodeClaim , _ int ) klog.ObjectRef {
120
- return klog .KObj (nc )
118
+ fmt .Errorf ("deleting nodeclaims, %w" , multierr .Combine (errs ... )),
119
+ "NodeClaims" , lo .FilterMap (errs , func (err error , i int ) (klog.ObjectRef , bool ) {
120
+ if err == nil {
121
+ return klog.ObjectRef {}, false
122
+ }
123
+ return klog .KObj (toDelete [i ]), true
121
124
}),
122
125
)
123
126
}
0 commit comments