Skip to content

Commit 3e7673a

Browse files
fix: Fix resource tracking when marking for deletion (#2142)
1 parent 9877cf6 commit 3e7673a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkg/controllers/state/cluster.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,32 +251,30 @@ func (c *Cluster) NominateNodeForPod(ctx context.Context, providerID string) {
251251
}
252252
}
253253

254-
// TODO remove this when v1alpha5 APIs are deprecated. With v1 APIs Karpenter relies on the existence
255-
// of the karpenter.sh/disruption taint to know when a node is marked for deletion.
256254
// UnmarkForDeletion removes the marking on the node as a node the controller intends to delete
257255
func (c *Cluster) UnmarkForDeletion(providerIDs ...string) {
258256
c.mu.Lock()
259257
defer c.mu.Unlock()
260258

261259
for _, id := range providerIDs {
262260
if n, ok := c.nodes[id]; ok {
263-
c.updateNodePoolResources(nil, c.nodes[id])
261+
oldNode := n.ShallowCopy()
264262
n.markedForDeletion = false
263+
c.updateNodePoolResources(oldNode, n)
265264
}
266265
}
267266
}
268267

269-
// TODO remove this when v1alpha5 APIs are deprecated. With v1 APIs Karpenter relies on the existence
270-
// of the karpenter.sh/disruption taint to know when a node is marked for deletion.
271268
// MarkForDeletion marks the node as pending deletion in the internal cluster state
272269
func (c *Cluster) MarkForDeletion(providerIDs ...string) {
273270
c.mu.Lock()
274271
defer c.mu.Unlock()
275272

276273
for _, id := range providerIDs {
277274
if n, ok := c.nodes[id]; ok {
278-
c.updateNodePoolResources(c.nodes[id], nil)
275+
oldNode := n.ShallowCopy()
279276
n.markedForDeletion = true
277+
c.updateNodePoolResources(oldNode, n)
280278
}
281279
}
282280
}

0 commit comments

Comments
 (0)