You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2021/02/08 12:07:31 UTC

[GitHub] [incubator-yunikorn-core] wilfred-s commented on a change in pull request #245: [YUNIKORN-519] Cleanup placeholders when the app is Completed

wilfred-s commented on a change in pull request #245:
URL: https://github.com/apache/incubator-yunikorn-core/pull/245#discussion_r571982267



##########
File path: pkg/scheduler/partition_test.go
##########
@@ -1172,6 +1172,41 @@ func TestCleanupCompletedApps(t *testing.T) {
 	assert.Assert(t, len(partition.GetAppsByState(objects.Expired.String())) == 0, "the partition should have 0 expired app")
 }
 
+func TestCleanupPlaceholders(t *testing.T) {
+	partition, err := newBasePartition()
+	assert.NilError(t, err, "partition create failed")
+	completedApp := newApplication("completed", "default", defQueue)
+	completedApp.SetState(objects.Completed.String())
+	res := resources.NewResourceFromMap(map[string]resources.Quantity{"first": 1})
+	ask := objects.NewAllocationAsk(&si.AllocationAsk{
+		AllocationKey:  "allocKey",
+		ApplicationID:  completedApp.ApplicationID,
+		PartitionName:  partition.Name,
+		ResourceAsk:    res.ToProto(),
+		MaxAllocations: 1,
+		Placeholder:    true,
+		TaskGroupName:  "tg",

Review comment:
       Can we factor this out into the `utilities_test.go` file and add it as the function: `newAllocationAskTG()` we will reuse that code in more tests.

##########
File path: pkg/scheduler/partition.go
##########
@@ -1207,6 +1207,25 @@ func (pc *PartitionContext) cleanupExpiredApps() {
 	}
 }
 
+func (pc *PartitionContext) cleanupPlaceholders() []*objects.Allocation {
+	var released []*objects.Allocation
+	for _, app := range pc.GetAppsByState(objects.Completed.String()) {
+		// at this point if we still have allocations those are placeholders
+		for _, alloc := range app.GetAllAllocations() {
+			r, _ := pc.removeAllocation(&si.AllocationRelease{
+				PartitionName:   pc.Name,
+				ApplicationID:   app.ApplicationID,
+				UUID:            alloc.UUID,
+				TerminationType: si.AllocationRelease_TIMEOUT,
+			})
+			released = append(released, r...)
+		}

Review comment:
       I think we can simplify this by calling `app.RemoveAllAllocations()` directly. We just want to clean up all that is left:
   ```
   released = append(released, app.RemoveAllAllocations()...)
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org