Skip to content

Commit 1515681

Browse files
authored
perf: Only call .Available() once which prevents duplicate allocs (#2241)
1 parent f3dddc9 commit 1515681

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/controllers/provisioning/scheduling/existingnode.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ func NewExistingNode(n *state.StateNode, topology *Topology, taints []v1.Taint,
5050
daemonResources[k] = v
5151
}
5252
}
53+
available := n.Available()
5354
node := &ExistingNode{
5455
StateNode: n,
55-
cachedAvailable: n.Available(),
56+
cachedAvailable: available,
5657
cachedTaints: taints,
5758
topology: topology,
58-
remainingResources: resources.Subtract(n.Available(), daemonResources),
59+
remainingResources: resources.Subtract(available, daemonResources),
5960
requirements: scheduling.NewLabelRequirements(n.Labels()),
6061
}
6162
node.requirements.Add(scheduling.NewRequirement(v1.LabelHostname, v1.NodeSelectorOpIn, n.HostName()))

0 commit comments

Comments
 (0)