adityadtu5 commented on code in PR #1062:
URL: https://github.com/apache/yunikorn-k8shim/pull/1062#discussion_r3772365366


##########
pkg/cache/task.go:
##########
@@ -669,6 +712,22 @@ func (task *Task) 
rollbackOnAssumePodFailure(allocationKey, nodeID string) {
                zap.String("allocationKey", allocationKey))
 }
 
+// rescheduleOnBindFailure is called when volume or pod binding fails after 
all retries.
+// It moves the task from Allocated back to Scheduling and rolls the 
allocation back to a
+// pending ask so the core can re-schedule it on a different node.
+// Must be called without holding the task lock.
+func (task *Task) rescheduleOnBindFailure(allocationKey, nodeID, eventReason, 
eventMsg string) {
+       // Move the task back to Scheduling before releasing to the core, so 
the re-delivered
+       // allocation (valid only from the Scheduling state) is accepted by the 
state machine.

Review Comment:
   thanks, done.



##########
pkg/cache/task.go:
##########
@@ -343,45 +353,70 @@ func (task *Task) postTaskPending() {
 // This routine binds the pod to the allocated node.
 // It calls K8s api to bind a pod to the assigned node, this may need some 
time,
 // so we do a delay binding, background process, to avoid blocking main 
process.
-// The result of the binding is tracked and failures are properly handled.
-// If successful, we move task to next state BOUND, otherwise we fail the task
+// Volume binding and pod binding are retried with a backoff; if they 
ultimately fail
+// the allocation is rolled back to a pending ask so the core can re-schedule 
the task
+// on a different node. On success we move the task to the next state BOUND.
 func (task *Task) postTaskAllocated() {
        go func() {
-               // we need to obtain task's lock first,
-               // this ensures no other threads modifying task state at the 
time being
-               task.lock.Lock()
-               defer task.lock.Unlock()
+               // Snapshot the fields needed for binding without holding the 
lock during the
+               // potentially slow bind calls. This avoids blocking other 
goroutines and lets the
+               // rollback/reschedule path (which acquires the lock) run when 
binding fails.
+               task.lock.RLock()
+               pod := task.pod
+               alias := task.alias
+               nodeName := task.nodeName
+               allocationKey := task.allocationKey
+               task.lock.RUnlock()

Review Comment:
   thanks, made these changes.



-- 
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