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


The following commit(s) were added to refs/heads/master by this push:
     new 505a5096 [YUNIKORN-2671] Convert Allocation releases field to singular 
(#890)
505a5096 is described below

commit 505a5096bbf1ec2f3ac898ce58468358b58865a0
Author: Craig Condit <[email protected]>
AuthorDate: Wed Jun 12 11:04:34 2024 -0500

    [YUNIKORN-2671] Convert Allocation releases field to singular (#890)
    
    The releases slice in the Allocation object is now redundant since
    multiple allocations for a single release are no longer allowed. Convert
    the releases slice into a single release reference instead.
    
    Closes: #890
---
 pkg/scheduler/context.go                  |  2 +-
 pkg/scheduler/objects/allocation.go       | 45 +++++++++++--------------------
 pkg/scheduler/objects/application.go      | 13 +++------
 pkg/scheduler/objects/application_test.go | 14 +++++-----
 pkg/scheduler/partition.go                | 12 ++++-----
 pkg/scheduler/partition_test.go           | 44 +++++++++++++++---------------
 6 files changed, 54 insertions(+), 76 deletions(-)

diff --git a/pkg/scheduler/context.go b/pkg/scheduler/context.go
index 2ecda58e..92748af9 100644
--- a/pkg/scheduler/context.go
+++ b/pkg/scheduler/context.go
@@ -143,7 +143,7 @@ func (cc *ClusterContext) schedule() bool {
                        
metrics.GetSchedulerMetrics().ObserveSchedulingLatency(schedulingStart)
                        if alloc.GetResult() == objects.Replaced {
                                // communicate the removal to the RM
-                               cc.notifyRMAllocationReleased(psc.RmID, 
psc.Name, alloc.GetReleasesClone(), si.TerminationType_PLACEHOLDER_REPLACED, 
"replacing allocationKey: "+alloc.GetAllocationKey())
+                               cc.notifyRMAllocationReleased(psc.RmID, 
psc.Name, []*objects.Allocation{alloc.GetRelease()}, 
si.TerminationType_PLACEHOLDER_REPLACED, "replacing allocationKey: 
"+alloc.GetAllocationKey())
                        } else {
                                cc.notifyRMNewAllocation(psc.RmID, alloc)
                        }
diff --git a/pkg/scheduler/objects/allocation.go 
b/pkg/scheduler/objects/allocation.go
index adde18b2..4e4f64d6 100644
--- a/pkg/scheduler/objects/allocation.go
+++ b/pkg/scheduler/objects/allocation.go
@@ -67,7 +67,7 @@ type Allocation struct {
        released              bool
        reservedNodeID        string
        result                AllocationResult
-       releases              []*Allocation
+       release               *Allocation
        preempted             bool
        instType              string
 
@@ -324,47 +324,32 @@ func (a *Allocation) SetResult(result AllocationResult) {
        a.result = result
 }
 
-// GetReleasesClone returns a clone of the release list
-func (a *Allocation) GetReleasesClone() []*Allocation {
+// GetRelease returns the associated release for this allocation
+func (a *Allocation) GetRelease() *Allocation {
        a.RLock()
        defer a.RUnlock()
-       result := make([]*Allocation, len(a.releases))
-       copy(result, a.releases)
-       return result
-}
-
-// GetFirstRelease returns the first release for this allocation
-func (a *Allocation) GetFirstRelease() *Allocation {
-       a.RLock()
-       defer a.RUnlock()
-       return a.releases[0]
+       return a.release
 }
 
-// GetReleaseCount gets the number of releases associated with this allocation
-func (a *Allocation) GetReleaseCount() int {
-       a.RLock()
-       defer a.RUnlock()
-       return len(a.releases)
-}
-
-// ClearReleases removes all releases from this allocation
-func (a *Allocation) ClearReleases() {
+// SetRelease sets the release for this allocation
+func (a *Allocation) SetRelease(release *Allocation) {
        a.Lock()
        defer a.Unlock()
-       a.releases = nil
+       a.release = release
 }
 
-// AddRelease adds a new release to this allocation
-func (a *Allocation) AddRelease(release *Allocation) {
+// ClearRelease removes all releases from this allocation
+func (a *Allocation) ClearRelease() {
        a.Lock()
        defer a.Unlock()
-       a.releases = append(a.releases, release)
+       a.release = nil
 }
 
-func (a *Allocation) SetRelease(release *Allocation) {
-       a.Lock()
-       defer a.Unlock()
-       a.releases = []*Allocation{release}
+// HasRelease determines if this allocation has an associated release
+func (a *Allocation) HasRelease() bool {
+       a.RLock()
+       defer a.RUnlock()
+       return a.release != nil
 }
 
 // GetAllocatedResource returns a reference to the allocated resources for 
this allocation. This must be treated as read-only.
diff --git a/pkg/scheduler/objects/application.go 
b/pkg/scheduler/objects/application.go
index 80769855..e638ed4c 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -1722,30 +1722,23 @@ func (sa *Application) ReplaceAllocation(allocationKey 
string) *Allocation {
        // remove the placeholder that was just confirmed by the shim
        ph := sa.removeAllocationInternal(allocationKey, 
si.TerminationType_PLACEHOLDER_REPLACED)
        // this has already been replaced or it is a duplicate message from the 
shim
-       if ph == nil || ph.GetReleaseCount() == 0 {
+       if ph == nil || !ph.HasRelease() {
                log.Log(log.SchedApplication).Debug("Unexpected placeholder 
released",
                        zap.String("applicationID", sa.ApplicationID),
                        zap.Stringer("placeholder", ph))
                return nil
        }
-       // weird issue we should never have more than 1 log it for debugging 
this error
-       if ph.GetReleaseCount() > 1 {
-               log.Log(log.SchedApplication).Error("Unexpected release number, 
placeholder released, only 1 real allocations processed",
-                       zap.String("applicationID", sa.ApplicationID),
-                       zap.String("placeholderKey", allocationKey),
-                       zap.Int("releases", ph.GetReleaseCount()))
-       }
        // update the replacing allocation
        // we double linked the real and placeholder allocation
        // ph is the placeholder, the releases entry points to the real one
-       alloc := ph.GetFirstRelease()
+       alloc := ph.GetRelease()
        alloc.SetPlaceholderUsed(true)
        alloc.SetPlaceholderCreateTime(ph.GetCreateTime())
        alloc.SetBindTime(time.Now())
        sa.addAllocationInternal(alloc)
        // order is important: clean up the allocation after adding it to the 
app
        // we need the original Replaced allocation result.
-       alloc.ClearReleases()
+       alloc.ClearRelease()
        alloc.SetResult(Allocated)
        if sa.placeholderData != nil {
                sa.placeholderData[ph.GetTaskGroup()].Replaced++
diff --git a/pkg/scheduler/objects/application_test.go 
b/pkg/scheduler/objects/application_test.go
index eb3df4bd..7f9625b8 100644
--- a/pkg/scheduler/objects/application_test.go
+++ b/pkg/scheduler/objects/application_test.go
@@ -1272,7 +1272,7 @@ func TestReplaceAllocation(t *testing.T) {
        // set the real one to replace the placeholder
        realAlloc := newAllocation(appID1, nodeID1, res)
        realAlloc.SetResult(Replaced)
-       ph.AddRelease(realAlloc)
+       ph.SetRelease(realAlloc)
        alloc = app.ReplaceAllocation(ph.GetAllocationKey())
        assert.Equal(t, alloc, ph, "returned allocation is not the placeholder")
        assert.Assert(t, resources.IsZero(app.allocatedPlaceholder), "real 
allocation counted as placeholder")
@@ -1285,7 +1285,7 @@ func TestReplaceAllocation(t *testing.T) {
 
        // add the placeholder back to the app, the failure test above changed 
state and removed the ph
        app.SetState(Running.String())
-       ph.ClearReleases()
+       ph.ClearRelease()
        app.AddAllocation(ph)
        app.addPlaceholderDataWithLocking(ph.GetAsk())
        assert.Equal(t, app.placeholderData[""].Count, int64(3))
@@ -1294,10 +1294,10 @@ func TestReplaceAllocation(t *testing.T) {
        // set multiple real allocations to replace the placeholder
        realAlloc = newAllocation(appID1, nodeID1, res)
        realAlloc.SetResult(Replaced)
-       ph.AddRelease(realAlloc)
+       ph.SetRelease(realAlloc)
        realAllocNoAdd := newAllocation(appID1, nodeID1, res)
        realAllocNoAdd.SetResult(Replaced)
-       ph.AddRelease(realAlloc)
+       ph.SetRelease(realAlloc)
        alloc = app.ReplaceAllocation(ph.GetAllocationKey())
        assert.Equal(t, alloc, ph, "returned allocation is not the placeholder")
        assert.Assert(t, resources.IsZero(app.allocatedPlaceholder), "real 
allocation counted as placeholder")
@@ -1346,21 +1346,21 @@ func TestReplaceAllocationTracking(t *testing.T) {
        // replace placeholders
        realAlloc1 := newAllocation(appID1, nodeID1, res)
        realAlloc1.SetResult(Replaced)
-       ph1.AddRelease(realAlloc1)
+       ph1.SetRelease(realAlloc1)
        alloc1 := app.ReplaceAllocation(ph1.GetAllocationKey())
        app.RemoveAllocation(ph1.GetAllocationKey(), 
si.TerminationType_PLACEHOLDER_REPLACED)
        assert.Equal(t, ph1.GetAllocationKey(), alloc1.GetAllocationKey())
        assert.Equal(t, true, app.HasPlaceholderAllocation())
        realAlloc2 := newAllocation(appID1, nodeID1, res)
        realAlloc2.SetResult(Replaced)
-       ph2.AddRelease(realAlloc2)
+       ph2.SetRelease(realAlloc2)
        alloc2 := app.ReplaceAllocation(ph2.GetAllocationKey())
        app.RemoveAllocation(ph2.GetAllocationKey(), 
si.TerminationType_PLACEHOLDER_REPLACED)
        assert.Equal(t, ph2.GetAllocationKey(), alloc2.GetAllocationKey())
        assert.Equal(t, true, app.HasPlaceholderAllocation())
        realAlloc3 := newAllocation(appID1, nodeID1, res)
        realAlloc3.SetResult(Replaced)
-       ph3.AddRelease(realAlloc3)
+       ph3.SetRelease(realAlloc3)
        alloc3 := app.ReplaceAllocation(ph3.GetAllocationKey())
        app.RemoveAllocation(ph3.GetAllocationKey(), 
si.TerminationType_PLACEHOLDER_REPLACED)
        assert.Equal(t, ph3.GetAllocationKey(), alloc3.GetAllocationKey())
diff --git a/pkg/scheduler/partition.go b/pkg/scheduler/partition.go
index fc2c5404..471d4312 100644
--- a/pkg/scheduler/partition.go
+++ b/pkg/scheduler/partition.go
@@ -716,8 +716,8 @@ func (pc *PartitionContext) removeNodeAllocations(node 
*objects.Node) ([]*object
                // Retrieve the queue early before a possible race.
                queue := app.GetQueue()
                // check for an inflight replacement.
-               if alloc.GetReleaseCount() != 0 {
-                       release := alloc.GetFirstRelease()
+               if alloc.HasRelease() {
+                       release := alloc.GetRelease()
                        // allocation to update the ask on: this needs to 
happen on the real alloc never the placeholder
                        askAlloc := alloc
                        // placeholder gets handled differently from normal
@@ -765,8 +765,8 @@ func (pc *PartitionContext) removeNodeAllocations(node 
*objects.Node) ([]*object
                                askAlloc = release
                        }
                        // unlink the placeholder and allocation
-                       release.ClearReleases()
-                       alloc.ClearReleases()
+                       release.ClearRelease()
+                       alloc.ClearRelease()
                        // mark ask as unallocated to get it re-scheduled
                        _, err := 
app.DeallocateAsk(askAlloc.GetAsk().GetAllocationKey())
                        if err == nil {
@@ -876,7 +876,7 @@ func (pc *PartitionContext) tryPlaceholderAllocate() 
*objects.Allocation {
                log.Log(log.SchedPartition).Info("scheduler replace placeholder 
processed",
                        zap.String("appID", alloc.GetApplicationID()),
                        zap.String("allocationKey", alloc.GetAllocationKey()),
-                       zap.String("placeholder released allocationKey", 
alloc.GetFirstRelease().GetAllocationKey()))
+                       zap.String("placeholder released allocationKey", 
alloc.GetRelease().GetAllocationKey()))
                // pass the release back to the RM via the cluster context
                return alloc
        }
@@ -1313,7 +1313,7 @@ func (pc *PartitionContext) removeAllocation(release 
*si.AllocationRelease) ([]*
                        continue
                }
                if release.TerminationType == 
si.TerminationType_PLACEHOLDER_REPLACED {
-                       confirmed = alloc.GetFirstRelease()
+                       confirmed = alloc.GetRelease()
                        // we need to check the resources equality
                        delta := 
resources.Sub(confirmed.GetAllocatedResource(), alloc.GetAllocatedResource())
                        // Any negative value in the delta means that at least 
one of the requested resource in the
diff --git a/pkg/scheduler/partition_test.go b/pkg/scheduler/partition_test.go
index 88ec551a..58daad55 100644
--- a/pkg/scheduler/partition_test.go
+++ b/pkg/scheduler/partition_test.go
@@ -391,7 +391,7 @@ func TestRemoveNodeWithPlaceholders(t *testing.T) {
        assert.Equal(t, 0, len(allocs), "expected no allocations for the app")
        assert.Assert(t, resources.Equals(app.GetPendingResource(), appRes), 
"app should have updated pending resources")
        // check the interim state of the placeholder involved
-       assert.Equal(t, 0, ph.GetReleaseCount(), "placeholder should have no 
releases linked anymore")
+       assert.Check(t, !ph.HasRelease(), "placeholder should not have release 
linked anymore")
        assertLimits(t, getTestUserGroup(), 
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 0}))
 }
 
@@ -802,7 +802,7 @@ func TestRemoveNodeWithReplacement(t *testing.T) {
        assert.Equal(t, 1, len(allocs), "expected one allocation for the app 
(real)")
        assert.Equal(t, alloc.GetAllocationKey(), allocs[0].GetAllocationKey(), 
"allocationKey for the app is not the same as the real allocation")
        assert.Equal(t, objects.Allocated, allocs[0].GetResult(), "allocation 
state should be allocated")
-       assert.Equal(t, 0, allocs[0].GetReleaseCount(), "real allocation should 
have no releases linked anymore")
+       assert.Check(t, !allocs[0].HasRelease(), "real allocation should not 
have release liked anymore")
        assertLimits(t, getTestUserGroup(), appRes)
 }
 
@@ -868,7 +868,7 @@ func TestRemoveNodeWithReal(t *testing.T) {
        allocs = app.GetAllAllocations()
        assert.Equal(t, 1, len(allocs), "expected one allocation for the app 
(placeholder")
        assert.Equal(t, ph.GetAllocationKey(), allocs[0].GetAllocationKey(), 
"allocationKey for the app is not the same as the real allocation")
-       assert.Equal(t, 0, ph.GetReleaseCount(), "no inflight replacements 
linked")
+       assert.Check(t, !ph.HasRelease(), "no inflight replacement linked")
        assertLimits(t, getTestUserGroup(), appRes)
 }
 
@@ -1578,7 +1578,7 @@ func TestTryAllocate(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey2, "expected ask 
alloc-2 to be allocated")
        assertUserGroupResourceMaxLimits(t, getTestUserGroup(), 
resources.Multiply(res, 1), expectedQueuesMaxLimits)
@@ -1589,7 +1589,7 @@ func TestTryAllocate(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID2, "expected application 
app-2 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
        assertUserGroupResourceMaxLimits(t, getTestUserGroup(), 
resources.Multiply(res, 2), expectedQueuesMaxLimits)
@@ -1600,7 +1600,7 @@ func TestTryAllocate(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
        assert.Assert(t, resources.IsZero(partition.root.GetPendingResource()), 
"pending resources should be set to zero")
@@ -1637,7 +1637,7 @@ func TestRequiredNodeReservation(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
        assertLimits(t, getTestUserGroup(), res)
@@ -1896,7 +1896,7 @@ func TestRequiredNodeAllocation(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
        assertLimits(t, getTestUserGroup(), res)
@@ -2032,7 +2032,7 @@ func TestPreemptionForRequiredNodeReservedAlloc(t 
*testing.T) {
        // check if updated (must be after allocate call)
        assert.Equal(t, 0, len(app.GetReservations()), "ask should have no 
longer be reserved")
        assert.Equal(t, alloc.GetResult(), objects.AllocatedReserved, "result 
is not the expected AllocatedReserved")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not be 
present")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey2, "expected ask 
alloc-2 to be allocated")
        assertUserGroupResourceMaxLimits(t, getTestUserGroup(), 
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 8000}), 
getExpectedQueuesLimitsForPreemption())
 }
@@ -2145,7 +2145,7 @@ func setupPreemption(t *testing.T) (*PartitionContext, 
*objects.Application, *ob
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc1.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc1.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc1.HasRelease(), "released allocation should not 
be present")
        assert.Equal(t, alloc1.GetApplicationID(), appID1, "expected 
application app-1 to be allocated")
        assert.Equal(t, alloc1.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
        assert.Equal(t, alloc1.GetNodeID(), nodeID1, "expected alloc-1 on 
node-1")
@@ -2163,7 +2163,7 @@ func setupPreemption(t *testing.T) (*PartitionContext, 
*objects.Application, *ob
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc2.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc2.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc2.HasRelease(), "released allocation should not 
be present")
        assert.Equal(t, alloc2.GetApplicationID(), appID1, "expected 
application app-1 to be allocated")
        assert.Equal(t, alloc2.GetAllocationKey(), allocKey2, "expected ask 
alloc-2 to be allocated")
        assert.Equal(t, alloc2.GetNodeID(), nodeID2, "expected alloc-2 on 
node-2")
@@ -2207,7 +2207,7 @@ func setupPreemptionForRequiredNode(t *testing.T) 
(*PartitionContext, *objects.A
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not be 
present")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
        assertUserGroupResourceMaxLimits(t, getTestUserGroup(), 
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 8000}), 
getExpectedQueuesLimitsForPreemptionWithRequiredNode())
@@ -2400,7 +2400,7 @@ func TestTryAllocateReserve(t *testing.T) {
        }
        assert.Equal(t, alloc.GetResult(), objects.AllocatedReserved, "result 
is not the expected allocated from reserved")
        assert.Equal(t, alloc.GetReservedNodeID(), "", "node should not be set 
for allocated from reserved")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not be 
present")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), "alloc-2", "expected ask 
alloc-2 to be allocated")
        assertLimits(t, getTestUserGroup(), 
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 1000}))
@@ -2421,7 +2421,7 @@ func TestTryAllocateReserve(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not be 
present")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), "alloc-1", "expected ask 
alloc-1 to be allocated")
        assertLimits(t, getTestUserGroup(), 
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 2000}))
@@ -3095,7 +3095,7 @@ func TestPlaceholderBiggerThanReal(t *testing.T) {
                t.Fatal("allocation should have matched placeholder")
        }
        assert.Equal(t, objects.Replaced, alloc.GetResult(), "expected 
replacement result to be returned")
-       assert.Equal(t, 1, alloc.GetReleaseCount(), "placeholder should have 
been linked")
+       assert.Check(t, alloc.HasRelease(), "placeholder should have been 
linked")
        // no updates yet on queue and node
        assert.Assert(t, resources.Equals(phRes, 
app.GetQueue().GetAllocatedResource()), "placeholder size should still be 
allocated on queue")
        assert.Assert(t, resources.Equals(phRes, node.GetAllocatedResource()), 
"placeholder size should still be allocated on node")
@@ -3388,9 +3388,9 @@ func TestTryPlaceholderAllocate(t *testing.T) {
        assert.Equal(t, 2, partition.GetTotalAllocationCount(), "placeholder 
replacement should not be counted as alloc")
        assert.Equal(t, 2, partition.getPhAllocationCount(), "placeholder 
allocation should be registered")
        assert.Equal(t, alloc.GetResult(), objects.Replaced, "result is not the 
expected allocated replaced")
-       assert.Equal(t, alloc.GetReleaseCount(), 1, "released allocations 
should have been 1")
+       assert.Check(t, alloc.HasRelease(), "released allocation should be 
present")
        assertLimits(t, getTestUserGroup(), resources.Multiply(res, 2))
-       phAllocationKey := alloc.GetFirstRelease().GetAllocationKey()
+       phAllocationKey := alloc.GetRelease().GetAllocationKey()
        // placeholder is not released until confirmed by the shim
        if !resources.Equals(app.GetPlaceholderResource(), 
resources.Multiply(res, 2)) {
                t.Fatalf("placeholder allocation not updated as expected: got 
%s, expected %s", app.GetPlaceholderResource(), resources.Multiply(res, 2))
@@ -3481,14 +3481,14 @@ func TestFailReplacePlaceholder(t *testing.T) {
        assert.Equal(t, partition.GetTotalAllocationCount(), 1, "placeholder 
replacement should not be counted as alloc")
        assert.Equal(t, partition.getPhAllocationCount(), 1, "placeholder 
allocation should not change")
        assert.Equal(t, alloc.GetResult(), objects.Replaced, "result is not the 
expected allocated replaced")
-       assert.Equal(t, alloc.GetReleaseCount(), 1, "released allocations 
should have been 1")
+       assert.Check(t, alloc.HasRelease(), "released allocation should be 
present")
        // allocation must be added as it is on a different node
        assert.Equal(t, alloc.GetNodeID(), nodeID2, "should be allocated on 
node-2")
        assert.Assert(t, resources.IsZero(app.GetAllocatedResource()), 
"allocated resources should be zero")
        assert.Assert(t, resources.Equals(node.GetAllocatedResource(), res), 
"node-1 allocation not updated as expected: got %s, expected %s", 
node.GetAllocatedResource(), res)
        assert.Assert(t, resources.Equals(node2.GetAllocatedResource(), res), 
"node-2 allocation not updated as expected: got %s, expected %s", 
node2.GetAllocatedResource(), res)
 
-       phAllocationKey := alloc.GetFirstRelease().GetAllocationKey()
+       phAllocationKey := alloc.GetRelease().GetAllocationKey()
        // placeholder is not released until confirmed by the shim
        assert.Assert(t, resources.Equals(app.GetPlaceholderResource(), res), 
"placeholder allocation not updated as expected: got %s, expected %s", 
app.GetPlaceholderResource(), resources.Multiply(res, 2))
        assertLimits(t, getTestUserGroup(), res)
@@ -3762,7 +3762,7 @@ func TestTryAllocateMaxRunning(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask alloc 
to be allocated")
        assert.Equal(t, app.CurrentState(), objects.Accepted.String(), 
"application should have moved to accepted state")
@@ -3788,7 +3788,7 @@ func TestTryAllocateMaxRunning(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID1, "expected application 
app-1 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), "alloc-2", "expected ask 
alloc-2 to be allocated")
        assert.Equal(t, app.CurrentState(), objects.Running.String(), 
"application should have moved to running state")
@@ -3807,7 +3807,7 @@ func TestTryAllocateMaxRunning(t *testing.T) {
                t.Fatal("allocation did not return any allocation")
        }
        assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not 
the expected allocated")
-       assert.Equal(t, alloc.GetReleaseCount(), 0, "released allocations 
should have been 0")
+       assert.Check(t, !alloc.HasRelease(), "released allocation should not 
exist")
        assert.Equal(t, alloc.GetApplicationID(), appID2, "expected application 
app-2 to be allocated")
        assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask 
alloc-1 to be allocated")
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to