chia7712 commented on code in PR #824:
URL: https://github.com/apache/yunikorn-k8shim/pull/824#discussion_r1576545637
##########
pkg/cache/context.go:
##########
@@ -633,21 +639,28 @@ func (ctx *Context) EventsToRegister(queueingHintFn
framework.QueueingHintFn) []
return ctx.predManager.EventsToRegister(queueingHintFn)
}
-// evaluate given predicates based on current context
+// IsPodFitNode evaluates given predicates based on current context
func (ctx *Context) IsPodFitNode(name, node string, allocate bool) error {
ctx.lock.RLock()
defer ctx.lock.RUnlock()
- if pod, ok := ctx.schedulerCache.GetPod(name); ok {
- // if pod exists in cache, try to run predicates
- if targetNode := ctx.schedulerCache.GetNode(node); targetNode
!= nil {
- // need to lock cache here as predicates need a stable
view into the cache
- ctx.schedulerCache.LockForReads()
- defer ctx.schedulerCache.UnlockForReads()
- _, err := ctx.predManager.Predicates(pod, targetNode,
allocate)
- return err
- }
+ var pod *v1.Pod
+ var ok bool
+ if pod, ok = ctx.schedulerCache.GetPod(name); !ok {
Review Comment:
this is unrelated to this PR, but the returned type of `GetPod` is
inconsistent to `GetNode`. Maybe we should align them
##########
pkg/cache/context.go:
##########
@@ -633,21 +639,28 @@ func (ctx *Context) EventsToRegister(queueingHintFn
framework.QueueingHintFn) []
return ctx.predManager.EventsToRegister(queueingHintFn)
}
-// evaluate given predicates based on current context
+// IsPodFitNode evaluates given predicates based on current context
func (ctx *Context) IsPodFitNode(name, node string, allocate bool) error {
ctx.lock.RLock()
defer ctx.lock.RUnlock()
- if pod, ok := ctx.schedulerCache.GetPod(name); ok {
- // if pod exists in cache, try to run predicates
- if targetNode := ctx.schedulerCache.GetNode(node); targetNode
!= nil {
- // need to lock cache here as predicates need a stable
view into the cache
- ctx.schedulerCache.LockForReads()
- defer ctx.schedulerCache.UnlockForReads()
- _, err := ctx.predManager.Predicates(pod, targetNode,
allocate)
- return err
- }
+ var pod *v1.Pod
+ var ok bool
+ if pod, ok = ctx.schedulerCache.GetPod(name); !ok {
+ return ErrorPodNotFound
Review Comment:
Should the error message include the pod name?
##########
pkg/cache/context.go:
##########
@@ -633,21 +639,28 @@ func (ctx *Context) EventsToRegister(queueingHintFn
framework.QueueingHintFn) []
return ctx.predManager.EventsToRegister(queueingHintFn)
}
-// evaluate given predicates based on current context
+// IsPodFitNode evaluates given predicates based on current context
func (ctx *Context) IsPodFitNode(name, node string, allocate bool) error {
ctx.lock.RLock()
defer ctx.lock.RUnlock()
- if pod, ok := ctx.schedulerCache.GetPod(name); ok {
- // if pod exists in cache, try to run predicates
- if targetNode := ctx.schedulerCache.GetNode(node); targetNode
!= nil {
- // need to lock cache here as predicates need a stable
view into the cache
- ctx.schedulerCache.LockForReads()
- defer ctx.schedulerCache.UnlockForReads()
- _, err := ctx.predManager.Predicates(pod, targetNode,
allocate)
- return err
- }
+ var pod *v1.Pod
+ var ok bool
+ if pod, ok = ctx.schedulerCache.GetPod(name); !ok {
+ return ErrorPodNotFound
+ }
+ // if pod exists in cache, try to run predicates
+ targetNode := ctx.schedulerCache.GetNode(node)
+ if targetNode == nil {
+ return ErrorNodeNotFound
Review Comment:
Should the error message include the node name?
--
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]