This is an automated email from the ASF dual-hosted git repository.
pbacsko pushed a commit to branch branch-1.5
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/branch-1.5 by this push:
new a958e6f2 [YUNIKORN-2632] Data race in IncAllocatedResource (#870)
a958e6f2 is described below
commit a958e6f2b0c16019523320e46ac903c535761fcf
Author: Peter Bacsko <[email protected]>
AuthorDate: Fri May 17 17:40:46 2024 +0200
[YUNIKORN-2632] Data race in IncAllocatedResource (#870)
Closes: #870
Signed-off-by: Peter Bacsko <[email protected]>
(cherry picked from commit 63a91f6994d3c0880df20a5a011939e52ae41dd2)
---
pkg/scheduler/objects/queue.go | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index c45b4ac5..84d9d7b5 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -1029,12 +1029,10 @@ func (sq *Queue) isRoot() bool {
// Guard against going over max resources if set
func (sq *Queue) IncAllocatedResource(alloc *resources.Resource, nodeReported
bool) error {
// check this queue: failure stops checks if the allocation is not part
of a node addition
- newAllocated := resources.Add(sq.allocatedResource, alloc)
- if !nodeReported {
- if !sq.resourceFitsMaxRes(newAllocated) {
- return fmt.Errorf("allocation (%v) puts queue '%s' over
maximum allocation (%v), current usage (%v)",
- alloc, sq.QueuePath, sq.maxResource,
sq.allocatedResource)
- }
+ fit, newAllocated := sq.allocatedResFits(alloc)
+ if !nodeReported && !fit {
+ return fmt.Errorf("allocation (%v) puts queue '%s' over maximum
allocation (%v), current usage (%v)",
+ alloc, sq.QueuePath, sq.maxResource,
sq.allocatedResource)
}
// check the parent: need to pass before updating
if sq.parent != nil {
@@ -1060,11 +1058,12 @@ func (sq *Queue) IncAllocatedResource(alloc
*resources.Resource, nodeReported bo
return nil
}
-// small helper method to access sq.maxResource and avoid Clone() call
-func (sq *Queue) resourceFitsMaxRes(res *resources.Resource) bool {
+// small helper method to access sq.maxResource+sq.allocatedResource and avoid
Clone() call
+func (sq *Queue) allocatedResFits(res *resources.Resource) (bool,
*resources.Resource) {
sq.RLock()
defer sq.RUnlock()
- return sq.maxResource.FitInMaxUndef(res)
+ newAllocated := resources.Add(sq.allocatedResource, res)
+ return sq.maxResource.FitInMaxUndef(newAllocated), newAllocated
}
// DecAllocatedResource decrement the allocated resources for this queue
(recursively)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]