mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #115797 from pohly/dra-test-driver-resource-limit-fix
e2e dra: fix resource limits in a mixed cluster
This commit is contained in:
commit
fa3d5730a4
@ -198,8 +198,9 @@ func (c *ExampleController) allocate(ctx context.Context, claim *resourcev1alpha
|
|||||||
// number of allocations (even spreading) or the most (packing).
|
// number of allocations (even spreading) or the most (packing).
|
||||||
node = viableNodes[rand.Intn(len(viableNodes))]
|
node = viableNodes[rand.Intn(len(viableNodes))]
|
||||||
logger.Info("picked a node ourselves", "selectedNode", selectedNode)
|
logger.Info("picked a node ourselves", "selectedNode", selectedNode)
|
||||||
} else if c.resources.MaxAllocations > 0 &&
|
} else if !contains(c.resources.Nodes, node) ||
|
||||||
c.countAllocations(node) >= c.resources.MaxAllocations {
|
c.resources.MaxAllocations > 0 &&
|
||||||
|
c.countAllocations(node) >= c.resources.MaxAllocations {
|
||||||
return nil, fmt.Errorf("resources exhausted on node %q", node)
|
return nil, fmt.Errorf("resources exhausted on node %q", node)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -292,7 +293,7 @@ func (c *ExampleController) UnsuitableNodes(ctx context.Context, pod *v1.Pod, cl
|
|||||||
// can only work if a node has capacity left
|
// can only work if a node has capacity left
|
||||||
// for all of them. Also, nodes that the driver
|
// for all of them. Also, nodes that the driver
|
||||||
// doesn't run on cannot be used.
|
// doesn't run on cannot be used.
|
||||||
if contains(c.resources.Nodes, node) &&
|
if !contains(c.resources.Nodes, node) ||
|
||||||
allocationsPerNode[node]+len(claims) > c.resources.MaxAllocations {
|
allocationsPerNode[node]+len(claims) > c.resources.MaxAllocations {
|
||||||
claim.UnsuitableNodes = append(claim.UnsuitableNodes, node)
|
claim.UnsuitableNodes = append(claim.UnsuitableNodes, node)
|
||||||
}
|
}
|
||||||
@ -305,7 +306,7 @@ func (c *ExampleController) UnsuitableNodes(ctx context.Context, pod *v1.Pod, cl
|
|||||||
for _, claim := range claims {
|
for _, claim := range claims {
|
||||||
claim.UnsuitableNodes = nil
|
claim.UnsuitableNodes = nil
|
||||||
for _, node := range potentialNodes {
|
for _, node := range potentialNodes {
|
||||||
if contains(c.resources.Nodes, node) &&
|
if !contains(c.resources.Nodes, node) ||
|
||||||
allocations+len(claims) > c.resources.MaxAllocations {
|
allocations+len(claims) > c.resources.MaxAllocations {
|
||||||
claim.UnsuitableNodes = append(claim.UnsuitableNodes, node)
|
claim.UnsuitableNodes = append(claim.UnsuitableNodes, node)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user