FrankYang0529 commented on PR #561:
URL: https://github.com/apache/yunikorn-core/pull/561#issuecomment-1587587529

   I tried to run `TestTryAllocatePreemptNode` multiple time and compared logs 
between expected and unexpected results. I found the different part is 
following:
   ```
   # expected
   2023-06-12T16:49:19.170+0800    DEBUG   objects/preemption.go:352       No 
RM callback plugin registered, using first selected node for preemption      
{"NodeID": "node1", "AllocationKey": "alloc3"}
   # unexpected
   2023-06-12T22:58:18.571+0800    DEBUG   objects/preemption.go:352       No 
RM callback plugin registered, using first selected node for preemption      
{"NodeID": "node2", "AllocationKey": "alloc3"}
   ```
   Above logs are from the following code, so I checked how we get 
`predicateChecks`.
   
https://github.com/apache/yunikorn-core/blob/d2d7ce89457cbbce140e2737098ae62f6a9d8fee/pkg/scheduler/objects/preemption.go#L351-L354
   
   We get `predicateChecks` by for-loop `p.nodeAvailableMap` and find fit nodes 
as following:
   
https://github.com/apache/yunikorn-core/blob/d2d7ce89457cbbce140e2737098ae62f6a9d8fee/pkg/scheduler/objects/preemption.go#L485-L512
   
   The problem is that Golang doesn't guarantee key order in map (we can run 
[this](https://go.dev/play/p/IEYV9Vy22wx) to check it). If we get `node2` first 
and it has same `StartIndex` with `node1`, we will preempt `node2`.
   
https://github.com/apache/yunikorn-core/blob/d2d7ce89457cbbce140e2737098ae62f6a9d8fee/pkg/scheduler/objects/preemption.go#L342-L345
   
   My suggestion is that we can sort by `NodeID` if `StartIndex` are same.
   
   cc @craigcondit @pbacsko @zhuqi-lucas.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to