brandboat commented on code in PR #873:
URL: https://github.com/apache/yunikorn-k8shim/pull/873#discussion_r1709809781
##########
pkg/cache/context.go:
##########
@@ -873,19 +873,23 @@ func (ctx *Context) StartPodAllocation(podKey string,
nodeID string) bool {
return ctx.schedulerCache.StartPodAllocation(podKey, nodeID)
}
-func (ctx *Context) notifyTaskComplete(appID, taskID string) {
+func (ctx *Context) NotifyTaskComplete(app *Application, taskID string) {
+ ctx.lock.Lock()
+ defer ctx.lock.Unlock()
Review Comment:
May I ask why do we need lock here ?
##########
pkg/cache/context.go:
##########
@@ -295,41 +295,41 @@ func (ctx *Context) UpdatePod(_, newObj interface{}) {
}
func (ctx *Context) updateYuniKornPod(appID string, pod *v1.Pod) {
- var app *Application
taskID := string(pod.UID)
- if app = ctx.getApplication(appID); app != nil {
+ app := ctx.getApplication(appID)
+ if app != nil {
if task := app.GetTask(taskID); task != nil {
task.setTaskPod(pod)
}
}
// treat terminated pods like a remove
if utils.IsPodTerminated(pod) {
- ctx.notifyTaskComplete(appID, taskID)
+ if app != nil {
Review Comment:
Perhaps we could move the condition `if app != nil ` back to
`notifyTaskComplete` and simplify `deleteYuniKornPod`
from
```go
if app := ctx.GetApplication(taskMeta.ApplicationID); app
!= nil {
ctx.notifyTaskComplete(taskMeta.ApplicationID,
taskMeta.TaskID)
}
```
to
```go
ctx.notifyTaskComplete(ctx.GetApplication(taskMeta.ApplicationID),
taskMeta.TaskID)
```
WDYT ?
##########
pkg/cache/context.go:
##########
@@ -873,19 +873,23 @@ func (ctx *Context) StartPodAllocation(podKey string,
nodeID string) bool {
return ctx.schedulerCache.StartPodAllocation(podKey, nodeID)
}
-func (ctx *Context) notifyTaskComplete(appID, taskID string) {
+func (ctx *Context) NotifyTaskComplete(app *Application, taskID string) {
Review Comment:
Why do we expose this method ?
--
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]