This is an automated email from the ASF dual-hosted git repository.
ccondit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git
The following commit(s) were added to refs/heads/master by this push:
new dfeee61d [YUNIKORN-2816] Clean up AllocationReleaseRequest logic (#895)
dfeee61d is described below
commit dfeee61df8c999a71a5bfe8dbdf11b109748de7e
Author: qzhu <[email protected]>
AuthorDate: Mon Aug 19 10:29:22 2024 -0500
[YUNIKORN-2816] Clean up AllocationReleaseRequest logic (#895)
Closes: #895
Signed-off-by: Craig Condit <[email protected]>
---
pkg/cache/task.go | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/pkg/cache/task.go b/pkg/cache/task.go
index c7773965..eccab00a 100644
--- a/pkg/cache/task.go
+++ b/pkg/cache/task.go
@@ -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 {
@@ -494,25 +494,31 @@ 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 {
+ // 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)))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]