Skip to content

Commit

Permalink
[YUNIKORN-2816] Clean up AllocationReleaseRequest logic and adjust co…
Browse files Browse the repository at this point in the history
…mments
  • Loading branch information
zhuqi-lucas committed Aug 17, 2024
1 parent 2278b32 commit 764fdd6
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pkg/cache/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func (task *Task) beforeTaskCompleted() {
"Task %s is completed", task.alias)
}

// releaseAllocation sends the release request for the Allocation or the AllocationAsk to the core.
// releaseAllocation sends the release request for the Allocation to the core.
func (task *Task) releaseAllocation() {
// scheduler api might be nil in some tests
if task.context.apiProvider.GetAPIs().SchedulerAPI != nil {
Expand All @@ -494,25 +494,32 @@ func (task *Task) releaseAllocation() {
zap.String("task", task.GetTaskState()),
zap.String("terminationType", task.terminationType))

// The message depends on current task state, generate requests accordingly.
// If allocated send an AllocationReleaseRequest,
// If not allocated yet send an AllocationAskReleaseRequest
// Send an AllocationReleaseRequest,
var releaseRequest *si.AllocationRequest
s := TaskStates()
switch task.GetTaskState() {
case s.New, s.Pending, s.Scheduling, s.Rejected:
releaseRequest = common.CreateReleaseRequestForTask(task.applicationID, task.taskID, task.application.partition, task.terminationType)
default:

// Check if the task is in a state where it has not been allocated yet.
if task.GetTaskState() != s.New && task.GetTaskState() != s.Pending &&
task.GetTaskState() != s.Scheduling && task.GetTaskState() != s.Rejected {

Check failure on line 503 in pkg/cache/task.go

View workflow job for this annotation

GitHub Actions / build

unnecessary leading newline (whitespace)

// Task is in a state where it might have been allocated.
if task.allocationKey == "" {
log.Log(log.ShimCacheTask).Warn("BUG: task allocationKey is empty on release",
zap.String("applicationID", task.applicationID),
zap.String("taskID", task.taskID),
zap.String("taskAlias", task.alias),
zap.String("task", task.GetTaskState()))
zap.String("taskState", task.GetTaskState()))
}
releaseRequest = common.CreateReleaseRequestForTask(task.applicationID, task.taskID, task.application.partition, task.terminationType)
}

// Create the release request.
releaseRequest = common.CreateReleaseRequestForTask(
task.applicationID,
task.taskID,
task.application.partition,
task.terminationType,
)

if releaseRequest.Releases != nil {
log.Log(log.ShimCacheTask).Info("releasing allocations",
zap.Int("numOfAllocationsToRelease", len(releaseRequest.Releases.AllocationsToRelease)))
Expand Down

0 comments on commit 764fdd6

Please sign in to comment.