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 cf838f90 [YUNIKORN-2587] Core: Convert AllocationID to AllocationKey
(#856)
cf838f90 is described below
commit cf838f90f0b6912b73c60d76079900702b679f69
Author: Craig Condit <[email protected]>
AuthorDate: Thu Apr 25 14:57:10 2024 -0500
[YUNIKORN-2587] Core: Convert AllocationID to AllocationKey (#856)
Having both AllocationID and AllocationKey in the core is redundant.
Replace all references to AllocationID with AllocationKey and remove
the duplicate variable in Allocation.
Closes: #856
---
go.mod | 2 +-
go.sum | 4 +-
pkg/examples/simple_example.go | 4 +-
pkg/scheduler/context.go | 3 +-
pkg/scheduler/health_checker.go | 2 +-
pkg/scheduler/objects/allocation.go | 24 +--
pkg/scheduler/objects/allocation_test.go | 13 +-
pkg/scheduler/objects/application.go | 25 ++-
pkg/scheduler/objects/application_events.go | 4 +-
pkg/scheduler/objects/application_events_test.go | 26 +--
pkg/scheduler/objects/application_test.go | 58 +++---
pkg/scheduler/objects/node.go | 32 +--
pkg/scheduler/objects/node_events.go | 8 +-
pkg/scheduler/objects/node_test.go | 25 ++-
pkg/scheduler/objects/preemption.go | 4 +-
pkg/scheduler/objects/queue_test.go | 2 +-
pkg/scheduler/objects/utilities_test.go | 17 +-
pkg/scheduler/partition.go | 82 ++++----
pkg/scheduler/partition_test.go | 252 +++++++++++------------
pkg/scheduler/tests/application_tracking_test.go | 6 +-
pkg/scheduler/tests/mock_rm_callback_test.go | 6 +-
pkg/scheduler/tests/mockscheduler_test.go | 8 +-
pkg/scheduler/tests/recovery_test.go | 26 +--
pkg/scheduler/tests/reservation_test.go | 2 +-
pkg/scheduler/tests/smoke_test.go | 10 +-
pkg/scheduler/utilities_test.go | 6 +-
pkg/webservice/dao/allocation_info.go | 2 -
pkg/webservice/handlers.go | 2 -
pkg/webservice/handlers_test.go | 4 -
29 files changed, 294 insertions(+), 365 deletions(-)
diff --git a/go.mod b/go.mod
index 7865af82..65b2c5a8 100644
--- a/go.mod
+++ b/go.mod
@@ -22,7 +22,7 @@ module github.com/apache/yunikorn-core
go 1.21
require (
- github.com/apache/yunikorn-scheduler-interface
v0.0.0-20240423191701-8c98b1604a7a
+ github.com/apache/yunikorn-scheduler-interface
v0.0.0-20240425182941-07f5695119a1
github.com/google/btree v1.1.2
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
diff --git a/go.sum b/go.sum
index a76cb0cd..35ee67e4 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-github.com/apache/yunikorn-scheduler-interface
v0.0.0-20240423191701-8c98b1604a7a
h1:H978zsTL2FvbRFnySO83DOFLO33PwHWFdmHvMoSVXsc=
-github.com/apache/yunikorn-scheduler-interface
v0.0.0-20240423191701-8c98b1604a7a/go.mod
h1:WuHJpVk34t8N5+1ErYGj/5Qq33/cRzL4YtuoAsbMtWc=
+github.com/apache/yunikorn-scheduler-interface
v0.0.0-20240425182941-07f5695119a1
h1:v4J9L3MlW8BQfYnbq6FV2l3uyay3SqMS2Ffpo+SFat4=
+github.com/apache/yunikorn-scheduler-interface
v0.0.0-20240425182941-07f5695119a1/go.mod
h1:WuHJpVk34t8N5+1ErYGj/5Qq33/cRzL4YtuoAsbMtWc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod
h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0
h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
diff --git a/pkg/examples/simple_example.go b/pkg/examples/simple_example.go
index 7cfaf864..d47ef59d 100644
--- a/pkg/examples/simple_example.go
+++ b/pkg/examples/simple_example.go
@@ -41,7 +41,7 @@ func (m *exampleRMCallback) UpdateAllocation(response
*si.AllocationResponse) er
m.Lock()
defer m.Unlock()
for _, alloc := range response.New {
- m.Allocations[alloc.AllocationID] = alloc
+ m.Allocations[alloc.AllocationKey] = alloc
if val, ok := m.nodeAllocations[alloc.NodeID]; ok {
val = append(val, alloc)
m.nodeAllocations[alloc.NodeID] = val
@@ -53,7 +53,7 @@ func (m *exampleRMCallback) UpdateAllocation(response
*si.AllocationResponse) er
}
for _, alloc := range response.Released {
- delete(m.Allocations, alloc.AllocationID)
+ delete(m.Allocations, alloc.AllocationKey)
}
return nil
}
diff --git a/pkg/scheduler/context.go b/pkg/scheduler/context.go
index bf97b419..3d514e67 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,
alloc.GetReleasesClone(), si.TerminationType_PLACEHOLDER_REPLACED, "replacing
allocationID: "+alloc.GetAllocationID())
+ cc.notifyRMAllocationReleased(psc.RmID,
alloc.GetReleasesClone(), si.TerminationType_PLACEHOLDER_REPLACED, "replacing
allocationKey: "+alloc.GetAllocationKey())
} else {
cc.notifyRMNewAllocation(psc.RmID, alloc)
}
@@ -898,7 +898,6 @@ func (cc *ClusterContext) notifyRMAllocationReleased(rmID
string, released []*ob
releaseEvent.ReleasedAllocations =
append(releaseEvent.ReleasedAllocations, &si.AllocationRelease{
ApplicationID: alloc.GetApplicationID(),
PartitionName: alloc.GetPartitionName(),
- AllocationID: alloc.GetAllocationID(),
TerminationType: terminationType,
Message: message,
AllocationKey: alloc.GetAllocationKey(),
diff --git a/pkg/scheduler/health_checker.go b/pkg/scheduler/health_checker.go
index e8ba9728..84c7947a 100644
--- a/pkg/scheduler/health_checker.go
+++ b/pkg/scheduler/health_checker.go
@@ -335,7 +335,7 @@ func checkAppAllocations(app *objects.Application, nodes
objects.NodeCollection)
orphanAllocationsOnApp := make([]*objects.Allocation, 0)
for _, alloc := range app.GetAllAllocations() {
if node := nodes.GetNode(alloc.GetNodeID()); node != nil {
- if node.GetAllocation(alloc.GetAllocationID()) == nil {
+ if node.GetAllocation(alloc.GetAllocationKey()) == nil {
orphanAllocationsOnApp =
append(orphanAllocationsOnApp, alloc)
}
} else {
diff --git a/pkg/scheduler/objects/allocation.go
b/pkg/scheduler/objects/allocation.go
index ddca67f7..dd4c1f99 100644
--- a/pkg/scheduler/objects/allocation.go
+++ b/pkg/scheduler/objects/allocation.go
@@ -57,7 +57,6 @@ type Allocation struct {
taskGroupName string // task group this allocation belongs to
placeholder bool // is this a placeholder allocation
nodeID string
- allocationID string
priority int32
tags map[string]string
allocatedResource *resources.Resource
@@ -92,7 +91,6 @@ func NewAllocation(nodeID string, ask *AllocationAsk)
*Allocation {
bindTime: time.Now(),
nodeID: nodeID,
partitionName:
common.GetPartitionNameWithoutClusterID(ask.GetPartitionName()),
- allocationID: ask.allocationKey,
tags: ask.GetTagsClone(),
priority: ask.GetPriority(),
allocatedResource: ask.GetAllocatedResource().Clone(),
@@ -104,7 +102,6 @@ func NewAllocation(nodeID string, ask *AllocationAsk)
*Allocation {
func newReservedAllocation(nodeID string, ask *AllocationAsk) *Allocation {
alloc := NewAllocation(nodeID, ask)
- alloc.allocationID = ""
alloc.SetBindTime(time.Time{})
alloc.SetResult(Reserved)
return alloc
@@ -112,7 +109,6 @@ func newReservedAllocation(nodeID string, ask
*AllocationAsk) *Allocation {
func newUnreservedAllocation(nodeID string, ask *AllocationAsk) *Allocation {
alloc := NewAllocation(nodeID, ask)
- alloc.allocationID = ""
alloc.SetBindTime(time.Time{})
alloc.SetResult(Unreserved)
return alloc
@@ -157,7 +153,7 @@ func NewAllocationFromSI(alloc *si.Allocation) *Allocation {
allowPreemptOther:
alloc.PreemptionPolicy.GetAllowPreemptOther(),
}
newAlloc := NewAllocation(alloc.NodeID, ask)
- newAlloc.allocationID = alloc.AllocationID
+ newAlloc.allocationKey = alloc.AllocationKey
return newAlloc
}
@@ -173,7 +169,6 @@ func (a *Allocation) NewSIFromAllocation() *si.Allocation {
NodeID: a.GetNodeID(),
ApplicationID: a.GetApplicationID(),
AllocationKey: a.GetAllocationKey(),
- AllocationID: a.GetAllocationID(),
ResourcePerAlloc: a.GetAllocatedResource().ToProto(), // needed
in tests for restore
TaskGroupName: a.GetTaskGroup(),
Placeholder: a.IsPlaceholder(),
@@ -191,11 +186,7 @@ func (a *Allocation) String() string {
}
a.RLock()
defer a.RUnlock()
- allocationID := a.allocationID
- if a.result == Reserved || a.result == Unreserved {
- allocationID = "N/A"
- }
- return fmt.Sprintf("applicationID=%s, allocationID=%s,
allocationKey=%s, Node=%s, result=%s", a.applicationID, allocationID,
a.allocationKey, a.nodeID, a.result.String())
+ return fmt.Sprintf("applicationID=%s, allocationKey=%s, Node=%s,
result=%s", a.applicationID, a.allocationKey, a.nodeID, a.result.String())
}
// GetAsk returns the ask associated with this allocation
@@ -301,17 +292,6 @@ func (a *Allocation) GetInstanceType() string {
return a.instType
}
-// GetAllocationID returns the allocationID for this allocation
-func (a *Allocation) GetAllocationID() string {
- return a.allocationID
-}
-
-// SetAllocationID set the allocationID for this allocation
-// only for tests
-func (a *Allocation) SetAllocationID(allocationID string) {
- a.allocationID = allocationID
-}
-
// GetPriority returns the priority of this allocation
func (a *Allocation) GetPriority() int32 {
return a.priority
diff --git a/pkg/scheduler/objects/allocation_test.go
b/pkg/scheduler/objects/allocation_test.go
index e1c1bfe4..475ba9d6 100644
--- a/pkg/scheduler/objects/allocation_test.go
+++ b/pkg/scheduler/objects/allocation_test.go
@@ -53,7 +53,7 @@ func TestNewAlloc(t *testing.T) {
if alloc == nil {
t.Fatal("NewAllocation create failed while it should not")
}
- assert.Equal(t, alloc.GetAllocationID(), "ask-1")
+ assert.Equal(t, alloc.GetAllocationKey(), "ask-1")
assert.Equal(t, alloc.GetResult(), Allocated, "New alloc should default
to result Allocated")
assert.Assert(t, resources.Equals(alloc.GetAllocatedResource(), res),
"Allocated resource not set correctly")
assert.Assert(t, !alloc.IsPlaceholder(), "ask should not have been a
placeholder")
@@ -62,7 +62,7 @@ func TestNewAlloc(t *testing.T) {
alloc.SetInstanceType(instType1)
assert.Equal(t, alloc.GetInstanceType(), instType1, "Instance type not
set as expected")
allocStr := alloc.String()
- expected := "applicationID=app-1, allocationID=ask-1,
allocationKey=ask-1, Node=node-1, result=Allocated"
+ expected := "applicationID=app-1, allocationKey=ask-1, Node=node-1,
result=Allocated"
assert.Equal(t, allocStr, expected, "Strings should have been equal")
assert.Assert(t, !alloc.IsPlaceholderUsed(), fmt.Sprintf("Alloc should
not be placeholder replacement by default: got %t, expected %t",
alloc.IsPlaceholderUsed(), false))
created := alloc.GetCreateTime()
@@ -90,10 +90,9 @@ func TestNewReservedAlloc(t *testing.T) {
t.Fatal("NewReservedAllocation create failed while it should
not")
}
assert.Equal(t, alloc.GetResult(), Reserved, "NewReservedAlloc should
have Reserved result")
- assert.Equal(t, alloc.GetAllocationID(), "", "NewReservedAlloc should
not have allocationID")
assert.Assert(t, resources.Equals(alloc.GetAllocatedResource(), res),
"Allocated resource not set correctly")
allocStr := alloc.String()
- expected := "applicationID=app-1, allocationID=N/A,
allocationKey=ask-1, Node=node-1, result=Reserved"
+ expected := "applicationID=app-1, allocationKey=ask-1, Node=node-1,
result=Reserved"
assert.Equal(t, allocStr, expected, "Strings should have been equal")
}
@@ -106,10 +105,9 @@ func TestNewUnreservedAlloc(t *testing.T) {
t.Fatal("NewReservedAllocation create failed while it should
not")
}
assert.Equal(t, alloc.GetResult(), Unreserved, "NewReservedAlloc should
have Reserved result")
- assert.Equal(t, alloc.GetAllocationID(), "", "NewReservedAlloc should
not have allocationID")
assert.Assert(t, resources.Equals(alloc.GetAllocatedResource(), res),
"Allocated resource not set correctly")
allocStr := alloc.String()
- expected := "applicationID=app-1, allocationID=N/A,
allocationKey=ask-1, Node=node-1, result=Unreserved"
+ expected := "applicationID=app-1, allocationKey=ask-1, Node=node-1,
result=Unreserved"
assert.Equal(t, allocStr, expected, "Strings should have been equal")
}
@@ -131,7 +129,6 @@ func TestSIFromAlloc(t *testing.T) {
assert.NilError(t, err, "Resource creation failed")
expectedSI := &si.Allocation{
AllocationKey: "ask-1",
- AllocationID: "ask-1",
NodeID: "node-1",
ApplicationID: "app-1",
ResourcePerAlloc: res.ToProto(),
@@ -152,7 +149,6 @@ func TestSIFromAlloc(t *testing.T) {
allocSI := alloc.NewSIFromAllocation()
assert.Equal(t, expectedSI.AllocationKey, allocSI.AllocationKey, "wrong
AllocationKey")
- assert.Equal(t, expectedSI.AllocationID, allocSI.AllocationID, "wrong
AllocationID")
assert.Equal(t, expectedSI.NodeID, allocSI.NodeID, "wrong NodeID")
assert.Equal(t, expectedSI.ApplicationID, allocSI.ApplicationID, "wrong
ApplicationID")
assert.Check(t, allocSI.Originator, "originator flag should be set")
@@ -186,7 +182,6 @@ func TestNewAllocFromSI(t *testing.T) {
tags[siCommon.CreationTime] = strconv.FormatInt(past, 10)
allocSI := &si.Allocation{
AllocationKey: "ask-1",
- AllocationID: "test-allocationid",
NodeID: "node-1",
ApplicationID: "app-1",
ResourcePerAlloc: res.ToProto(),
diff --git a/pkg/scheduler/objects/application.go
b/pkg/scheduler/objects/application.go
index 3c0e0179..8b280891 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -1140,7 +1140,7 @@ func (sa *Application)
tryPlaceholderAllocate(nodeIterator func() NodeIterator,
if delta.HasNegativeValue() {
log.Log(log.SchedApplication).Warn("releasing
placeholder: real allocation is larger than placeholder",
zap.Stringer("requested resource",
request.GetAllocatedResource()),
- zap.String("placeholderID",
ph.GetAllocationID()),
+ zap.String("placeholderKey",
ph.GetAllocationKey()),
zap.Stringer("placeholder resource",
ph.GetAllocatedResource()))
// release the placeholder and tell the RM
ph.SetReleased(true)
@@ -1506,7 +1506,7 @@ func (sa *Application) tryNode(node *Node, ask
*AllocationAsk) *Allocation {
log.Log(log.SchedApplication).DPanic("queue update
failed unexpectedly",
zap.Error(err))
// revert the node update
- node.RemoveAllocation(alloc.GetAllocationID())
+ node.RemoveAllocation(alloc.GetAllocationKey())
return nil
}
// mark this ask as allocated
@@ -1668,7 +1668,7 @@ func (sa *Application) addAllocationInternal(info
*Allocation) {
sa.maxAllocatedResource =
resources.ComponentWiseMax(sa.allocatedResource, sa.maxAllocatedResource)
}
sa.appEvents.sendNewAllocationEvent(info)
- sa.allocations[info.GetAllocationID()] = info
+ sa.allocations[info.GetAllocationKey()] = info
}
// Increase user resource usage
@@ -1716,11 +1716,11 @@ func (sa *Application) updatePreemptedResource(info
*Allocation) {
info.GetAllocatedResource(), info.GetBindTime())
}
-func (sa *Application) ReplaceAllocation(allocationID string) *Allocation {
+func (sa *Application) ReplaceAllocation(allocationKey string) *Allocation {
sa.Lock()
defer sa.Unlock()
// remove the placeholder that was just confirmed by the shim
- ph := sa.removeAllocationInternal(allocationID,
si.TerminationType_PLACEHOLDER_REPLACED)
+ 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 {
log.Log(log.SchedApplication).Debug("Unexpected placeholder
released",
@@ -1732,7 +1732,7 @@ func (sa *Application) ReplaceAllocation(allocationID
string) *Allocation {
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("placeholderID", allocationID),
+ zap.String("placeholderKey", allocationKey),
zap.Int("releases", ph.GetReleaseCount()))
}
// update the replacing allocation
@@ -1756,16 +1756,16 @@ func (sa *Application) ReplaceAllocation(allocationID
string) *Allocation {
// Remove the Allocation from the application.
// Return the allocation that was removed or nil if not found.
-func (sa *Application) RemoveAllocation(allocationID string, releaseType
si.TerminationType) *Allocation {
+func (sa *Application) RemoveAllocation(allocationKey string, releaseType
si.TerminationType) *Allocation {
sa.Lock()
defer sa.Unlock()
- return sa.removeAllocationInternal(allocationID, releaseType)
+ return sa.removeAllocationInternal(allocationKey, releaseType)
}
// Remove the Allocation from the application
// No locking must be called while holding the lock
-func (sa *Application) removeAllocationInternal(allocationID string,
releaseType si.TerminationType) *Allocation {
- alloc := sa.allocations[allocationID]
+func (sa *Application) removeAllocationInternal(allocationKey string,
releaseType si.TerminationType) *Allocation {
+ alloc := sa.allocations[allocationKey]
// When app has the allocation, update map, and update allocated
resource of the app
if alloc == nil {
@@ -1830,7 +1830,7 @@ func (sa *Application)
removeAllocationInternal(allocationID string, releaseType
zap.Error(err))
}
}
- delete(sa.allocations, allocationID)
+ delete(sa.allocations, allocationKey)
sa.appEvents.sendRemoveAllocationEvent(alloc, releaseType)
return alloc
}
@@ -1959,7 +1959,6 @@ func (sa *Application) notifyRMAllocationReleased(rmID
string, released []*Alloc
ApplicationID: alloc.GetApplicationID(),
PartitionName: alloc.GetPartitionName(),
AllocationKey: alloc.GetAllocationKey(),
- AllocationID: alloc.GetAllocationID(),
TerminationType: terminationType,
Message: message,
})
@@ -2001,7 +2000,7 @@ func (sa *Application) notifyRMAllocationAskReleased(rmID
string, released []*Al
func (sa *Application) IsAllocationAssignedToApp(alloc *Allocation) bool {
sa.RLock()
defer sa.RUnlock()
- _, ok := sa.allocations[alloc.GetAllocationID()]
+ _, ok := sa.allocations[alloc.GetAllocationKey()]
return ok
}
diff --git a/pkg/scheduler/objects/application_events.go
b/pkg/scheduler/objects/application_events.go
index 8c407674..bb94ffbf 100644
--- a/pkg/scheduler/objects/application_events.go
+++ b/pkg/scheduler/objects/application_events.go
@@ -44,7 +44,7 @@ func (evt *applicationEvents) sendNewAllocationEvent(alloc
*Allocation) {
if !evt.eventSystem.IsEventTrackingEnabled() {
return
}
- event := events.CreateAppEventRecord(evt.app.ApplicationID,
common.Empty, alloc.GetAllocationID(), si.EventRecord_ADD,
si.EventRecord_APP_ALLOC, alloc.GetAllocatedResource())
+ event := events.CreateAppEventRecord(evt.app.ApplicationID,
common.Empty, alloc.GetAllocationKey(), si.EventRecord_ADD,
si.EventRecord_APP_ALLOC, alloc.GetAllocatedResource())
evt.eventSystem.AddEvent(event)
}
@@ -75,7 +75,7 @@ func (evt *applicationEvents) sendRemoveAllocationEvent(alloc
*Allocation, termi
eventChangeDetail = si.EventRecord_ALLOC_REPLACED
}
- event := events.CreateAppEventRecord(evt.app.ApplicationID,
common.Empty, alloc.GetAllocationID(), si.EventRecord_REMOVE,
eventChangeDetail, alloc.GetAllocatedResource())
+ event := events.CreateAppEventRecord(evt.app.ApplicationID,
common.Empty, alloc.GetAllocationKey(), si.EventRecord_REMOVE,
eventChangeDetail, alloc.GetAllocatedResource())
evt.eventSystem.AddEvent(event)
}
diff --git a/pkg/scheduler/objects/application_events_test.go
b/pkg/scheduler/objects/application_events_test.go
index 082ffc61..8cb10628 100644
--- a/pkg/scheduler/objects/application_events_test.go
+++ b/pkg/scheduler/objects/application_events_test.go
@@ -19,9 +19,10 @@
package objects
import (
- "gotest.tools/v3/assert"
"testing"
+ "gotest.tools/v3/assert"
+
"github.com/apache/yunikorn-core/pkg/common"
"github.com/apache/yunikorn-core/pkg/events/mock"
"github.com/apache/yunikorn-scheduler-interface/lib/go/si"
@@ -84,14 +85,13 @@ func TestSendNewAllocationEvent(t *testing.T) {
appEvents.sendNewAllocationEvent(&Allocation{
applicationID: appID0,
allocationKey: aKey,
- allocationID: aAllocationID,
})
assert.Equal(t, 1, len(eventSystem.Events), "event was not generated")
assert.Equal(t, si.EventRecord_APP, eventSystem.Events[0].Type, "event
type is not expected")
assert.Equal(t, si.EventRecord_ADD,
eventSystem.Events[0].EventChangeType, "event change type is not expected")
assert.Equal(t, si.EventRecord_APP_ALLOC,
eventSystem.Events[0].EventChangeDetail, "event change detail is not expected")
assert.Equal(t, appID0, eventSystem.Events[0].ObjectID, "event object
id is not expected")
- assert.Equal(t, aAllocationID, eventSystem.Events[0].ReferenceID,
"event reference id is not expected")
+ assert.Equal(t, aKey, eventSystem.Events[0].ReferenceID, "event
reference id is not expected")
assert.Equal(t, common.Empty, eventSystem.Events[0].Message, "message
is not expected")
}
@@ -147,61 +147,61 @@ func TestSendRemoveAllocationEvent(t *testing.T) {
name: "remove allocation cause of node
removal",
eventSystemMock: mock.NewEventSystem(),
terminationType:
si.TerminationType_UNKNOWN_TERMINATION_TYPE,
- allocation: &Allocation{applicationID:
appID0, allocationKey: aKey, allocationID: aAllocationID},
+ allocation: &Allocation{applicationID:
appID0, allocationKey: aKey},
expectedEventCnt: 1,
expectedType: si.EventRecord_APP,
expectedChangeType: si.EventRecord_REMOVE,
expectedChangeDetail: si.EventRecord_ALLOC_NODEREMOVED,
expectedObjectID: appID0,
- expectedReferenceID: aAllocationID,
+ expectedReferenceID: aKey,
},
{
name: "remove allocation cause of
resource manager cancel",
eventSystemMock: mock.NewEventSystem(),
terminationType: si.TerminationType_STOPPED_BY_RM,
- allocation: &Allocation{applicationID:
appID0, allocationKey: aKey, allocationID: aAllocationID},
+ allocation: &Allocation{applicationID:
appID0, allocationKey: aKey},
expectedEventCnt: 1,
expectedType: si.EventRecord_APP,
expectedChangeType: si.EventRecord_REMOVE,
expectedChangeDetail: si.EventRecord_ALLOC_CANCEL,
expectedObjectID: appID0,
- expectedReferenceID: aAllocationID,
+ expectedReferenceID: aKey,
},
{
name: "remove allocation cause of
timeout",
eventSystemMock: mock.NewEventSystem(),
terminationType: si.TerminationType_TIMEOUT,
- allocation: &Allocation{applicationID:
appID0, allocationKey: aKey, allocationID: aAllocationID},
+ allocation: &Allocation{applicationID:
appID0, allocationKey: aKey},
expectedEventCnt: 1,
expectedType: si.EventRecord_APP,
expectedChangeType: si.EventRecord_REMOVE,
expectedChangeDetail: si.EventRecord_ALLOC_TIMEOUT,
expectedObjectID: appID0,
- expectedReferenceID: aAllocationID,
+ expectedReferenceID: aKey,
},
{
name: "remove allocation cause of
preemption",
eventSystemMock: mock.NewEventSystem(),
terminationType:
si.TerminationType_PREEMPTED_BY_SCHEDULER,
- allocation: &Allocation{applicationID:
appID0, allocationKey: aKey, allocationID: aAllocationID},
+ allocation: &Allocation{applicationID:
appID0, allocationKey: aKey},
expectedEventCnt: 1,
expectedType: si.EventRecord_APP,
expectedChangeType: si.EventRecord_REMOVE,
expectedChangeDetail: si.EventRecord_ALLOC_PREEMPT,
expectedObjectID: appID0,
- expectedReferenceID: aAllocationID,
+ expectedReferenceID: aKey,
},
{
name: "remove allocation cause of
replacement",
eventSystemMock: mock.NewEventSystem(),
terminationType:
si.TerminationType_PLACEHOLDER_REPLACED,
- allocation: &Allocation{applicationID:
appID0, allocationKey: aKey, allocationID: aAllocationID},
+ allocation: &Allocation{applicationID:
appID0, allocationKey: aKey},
expectedEventCnt: 1,
expectedType: si.EventRecord_APP,
expectedChangeType: si.EventRecord_REMOVE,
expectedChangeDetail: si.EventRecord_ALLOC_REPLACED,
expectedObjectID: appID0,
- expectedReferenceID: aAllocationID,
+ expectedReferenceID: aKey,
},
}
for _, testCase := range testCases {
diff --git a/pkg/scheduler/objects/application_test.go
b/pkg/scheduler/objects/application_test.go
index 83984d34..eab5ae5b 100644
--- a/pkg/scheduler/objects/application_test.go
+++ b/pkg/scheduler/objects/application_test.go
@@ -904,7 +904,7 @@ func TestAllocations(t *testing.T) {
assert.Equal(t, len(allocs), 3)
assertUserGroupResource(t, getTestUserGroup(), resources.Multiply(res,
3))
// remove one of the 3
- if alloc = app.RemoveAllocation(alloc.GetAllocationID(),
si.TerminationType_UNKNOWN_TERMINATION_TYPE); alloc == nil {
+ if alloc = app.RemoveAllocation(alloc.GetAllocationKey(),
si.TerminationType_UNKNOWN_TERMINATION_TYPE); alloc == nil {
t.Error("returned allocations was nil allocation was not
removed")
}
assertUserGroupResource(t, getTestUserGroup(), resources.Multiply(res,
2))
@@ -1106,7 +1106,7 @@ func TestResourceUsageAggregation(t *testing.T) {
assertUserGroupResource(t, getTestUserGroup(), resources.Multiply(res,
2))
// remove one of the 2
- if alloc = app.RemoveAllocation(alloc.GetAllocationID(),
si.TerminationType_UNKNOWN_TERMINATION_TYPE); alloc == nil {
+ if alloc = app.RemoveAllocation(alloc.GetAllocationKey(),
si.TerminationType_UNKNOWN_TERMINATION_TYPE); alloc == nil {
t.Error("returned allocations was nil allocation was not
removed")
}
assertUserGroupResource(t, getTestUserGroup(), resources.Multiply(res,
1))
@@ -1258,7 +1258,7 @@ func TestReplaceAllocation(t *testing.T) {
t.Fatalf("placeholder allocation not updated as expected: got
%s, expected %s", app.allocatedPlaceholder, res)
}
assertUserGroupResource(t, getTestUserGroup(), res)
- alloc = app.ReplaceAllocation(ph.GetAllocationID())
+ alloc = app.ReplaceAllocation(ph.GetAllocationKey())
assert.Equal(t, alloc, nilAlloc, "placeholder without releases expected
nil to be returned got a real alloc: %s", alloc)
assert.Equal(t, app.placeholderData[""].Replaced, int64(0))
assertUserGroupResource(t, getTestUserGroup(), nil)
@@ -1273,7 +1273,7 @@ func TestReplaceAllocation(t *testing.T) {
realAlloc := newAllocation(appID1, nodeID1, res)
realAlloc.SetResult(Replaced)
ph.AddRelease(realAlloc)
- alloc = app.ReplaceAllocation(ph.GetAllocationID())
+ 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")
if !resources.Equals(app.allocatedResource, res) {
@@ -1298,7 +1298,7 @@ func TestReplaceAllocation(t *testing.T) {
realAllocNoAdd := newAllocation(appID1, nodeID1, res)
realAllocNoAdd.SetResult(Replaced)
ph.AddRelease(realAlloc)
- alloc = app.ReplaceAllocation(ph.GetAllocationID())
+ 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")
assert.Equal(t, app.placeholderData[""].Replaced, int64(2))
@@ -1347,23 +1347,23 @@ func TestReplaceAllocationTracking(t *testing.T) {
realAlloc1 := newAllocation(appID1, nodeID1, res)
realAlloc1.SetResult(Replaced)
ph1.AddRelease(realAlloc1)
- alloc1 := app.ReplaceAllocation(ph1.GetAllocationID())
- app.RemoveAllocation(ph1.GetAllocationID(),
si.TerminationType_PLACEHOLDER_REPLACED)
- assert.Equal(t, ph1.GetAllocationID(), alloc1.GetAllocationID())
+ 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)
- alloc2 := app.ReplaceAllocation(ph2.GetAllocationID())
- app.RemoveAllocation(ph2.GetAllocationID(),
si.TerminationType_PLACEHOLDER_REPLACED)
- assert.Equal(t, ph2.GetAllocationID(), alloc2.GetAllocationID())
+ 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)
- alloc3 := app.ReplaceAllocation(ph3.GetAllocationID())
- app.RemoveAllocation(ph3.GetAllocationID(),
si.TerminationType_PLACEHOLDER_REPLACED)
- assert.Equal(t, ph3.GetAllocationID(), alloc3.GetAllocationID())
+ alloc3 := app.ReplaceAllocation(ph3.GetAllocationKey())
+ app.RemoveAllocation(ph3.GetAllocationKey(),
si.TerminationType_PLACEHOLDER_REPLACED)
+ assert.Equal(t, ph3.GetAllocationKey(), alloc3.GetAllocationKey())
assert.Equal(t, false, app.HasPlaceholderAllocation())
// check placeholder resource usage
@@ -1511,7 +1511,7 @@ func TestTimeoutPlaceholderAllocReleased(t *testing.T) {
for _, event := range events {
if allocRelease, ok :=
event.(*rmevent.RMReleaseAllocationEvent); ok {
assert.Equal(t, len(allocRelease.ReleasedAllocations),
1, "one allocation should have been released")
- assert.Equal(t,
allocRelease.ReleasedAllocations[0].AllocationID, ph.allocationID, "wrong
placeholder allocation released on timeout")
+ assert.Equal(t,
allocRelease.ReleasedAllocations[0].AllocationKey, ph.allocationKey, "wrong
placeholder allocation released on timeout")
found = true
}
if _, ok := event.(*rmevent.RMReleaseAllocationAskEvent); ok {
@@ -1550,7 +1550,7 @@ func TestTimeoutPlaceholderCompleting(t *testing.T) {
app.SetState(Running.String())
assertUserGroupResource(t, getTestUserGroup(), resources.Multiply(res,
2))
// remove allocation to trigger state change
- app.RemoveAllocation(alloc.GetAllocationID(),
si.TerminationType_UNKNOWN_TERMINATION_TYPE)
+ app.RemoveAllocation(alloc.GetAllocationKey(),
si.TerminationType_UNKNOWN_TERMINATION_TYPE)
assert.Assert(t, app.IsCompleting(), "App should be in completing state
all allocs have been removed")
assertUserGroupResource(t, getTestUserGroup(), resources.Multiply(res,
1))
// make sure the placeholders time out
@@ -2101,8 +2101,8 @@ func TestAllocationEvents(t *testing.T) { //nolint:funlen
// add + remove
app.AddAllocation(alloc1)
app.AddAllocation(alloc2)
- app.RemoveAllocation(alloc1.GetAllocationID(),
si.TerminationType_STOPPED_BY_RM)
- app.RemoveAllocation(alloc2.GetAllocationID(),
si.TerminationType_PLACEHOLDER_REPLACED)
+ app.RemoveAllocation(alloc1.GetAllocationKey(),
si.TerminationType_STOPPED_BY_RM)
+ app.RemoveAllocation(alloc2.GetAllocationKey(),
si.TerminationType_PLACEHOLDER_REPLACED)
noEvents := uint64(0)
err = common.WaitFor(10*time.Millisecond, time.Second, func() bool {
noEvents = eventSystem.Store.CountStoredEvents()
@@ -2115,28 +2115,28 @@ func TestAllocationEvents(t *testing.T) {
//nolint:funlen
assert.Equal(t, si.EventRecord_APP, records[1].Type)
assert.Equal(t, si.EventRecord_ADD, records[1].EventChangeType)
assert.Equal(t, si.EventRecord_APP_ALLOC, records[1].EventChangeDetail)
- assert.Equal(t, alloc1.GetAllocationID(), records[1].ReferenceID)
+ assert.Equal(t, alloc1.GetAllocationKey(), records[1].ReferenceID)
assert.Equal(t, "app-1", records[1].ObjectID)
assert.Equal(t, si.EventRecord_APP, records[2].Type)
assert.Equal(t, si.EventRecord_ADD, records[2].EventChangeType)
assert.Equal(t, si.EventRecord_APP_ALLOC, records[2].EventChangeDetail)
- assert.Equal(t, alloc2.GetAllocationID(), records[2].ReferenceID)
+ assert.Equal(t, alloc2.GetAllocationKey(), records[2].ReferenceID)
assert.Equal(t, "app-1", records[2].ObjectID)
assert.Equal(t, si.EventRecord_APP, records[3].Type)
assert.Equal(t, si.EventRecord_REMOVE, records[3].EventChangeType)
assert.Equal(t, si.EventRecord_ALLOC_CANCEL,
records[3].EventChangeDetail)
- assert.Equal(t, alloc1.GetAllocationID(), records[3].ReferenceID)
+ assert.Equal(t, alloc1.GetAllocationKey(), records[3].ReferenceID)
assert.Equal(t, "app-1", records[3].ObjectID)
assert.Equal(t, si.EventRecord_APP, records[4].Type)
assert.Equal(t, si.EventRecord_REMOVE, records[4].EventChangeType)
assert.Equal(t, si.EventRecord_ALLOC_REPLACED,
records[4].EventChangeDetail)
- assert.Equal(t, alloc2.GetAllocationID(), records[4].ReferenceID)
+ assert.Equal(t, alloc2.GetAllocationKey(), records[4].ReferenceID)
assert.Equal(t, "app-1", records[4].ObjectID)
// add + replace
alloc1.placeholder = true
app.AddAllocation(alloc1)
- app.ReplaceAllocation(alloc1.GetAllocationID())
+ app.ReplaceAllocation(alloc1.GetAllocationKey())
noEvents = 0
err = common.WaitFor(10*time.Millisecond, time.Second, func() bool {
noEvents = eventSystem.Store.CountStoredEvents()
@@ -2148,12 +2148,12 @@ func TestAllocationEvents(t *testing.T) {
//nolint:funlen
assert.Equal(t, si.EventRecord_APP, records[0].Type)
assert.Equal(t, si.EventRecord_ADD, records[0].EventChangeType)
assert.Equal(t, si.EventRecord_APP_ALLOC, records[0].EventChangeDetail)
- assert.Equal(t, alloc1.GetAllocationID(), records[0].ReferenceID)
+ assert.Equal(t, alloc1.GetAllocationKey(), records[0].ReferenceID)
assert.Equal(t, "app-1", records[0].ObjectID)
assert.Equal(t, si.EventRecord_APP, records[1].Type)
assert.Equal(t, si.EventRecord_REMOVE, records[1].EventChangeType)
assert.Equal(t, si.EventRecord_ALLOC_REPLACED,
records[1].EventChangeDetail)
- assert.Equal(t, alloc1.GetAllocationID(), records[0].ReferenceID)
+ assert.Equal(t, alloc1.GetAllocationKey(), records[0].ReferenceID)
assert.Equal(t, "app-1", records[0].ObjectID)
// add + remove all
@@ -2171,12 +2171,12 @@ func TestAllocationEvents(t *testing.T) {
//nolint:funlen
assert.Equal(t, si.EventRecord_APP, records[0].Type)
assert.Equal(t, si.EventRecord_ADD, records[0].EventChangeType)
assert.Equal(t, si.EventRecord_APP_ALLOC, records[0].EventChangeDetail)
- assert.Equal(t, alloc1.GetAllocationID(), records[0].ReferenceID)
+ assert.Equal(t, alloc1.GetAllocationKey(), records[0].ReferenceID)
assert.Equal(t, "app-1", records[0].ObjectID)
assert.Equal(t, si.EventRecord_APP, records[1].Type)
assert.Equal(t, si.EventRecord_ADD, records[1].EventChangeType)
assert.Equal(t, si.EventRecord_APP_ALLOC, records[1].EventChangeDetail)
- assert.Equal(t, alloc2.GetAllocationID(), records[1].ReferenceID)
+ assert.Equal(t, alloc2.GetAllocationKey(), records[1].ReferenceID)
assert.Equal(t, "app-1", records[1].ObjectID)
assert.Equal(t, si.EventRecord_APP, records[2].Type)
assert.Equal(t, si.EventRecord_REMOVE, records[2].EventChangeType)
@@ -2188,8 +2188,8 @@ func TestAllocationEvents(t *testing.T) { //nolint:funlen
assert.Equal(t, si.EventRecord_ALLOC_CANCEL,
records[3].EventChangeDetail)
refIdsRemoved[records[3].ReferenceID]++
assert.Equal(t, "app-1", records[3].ObjectID)
- assert.Equal(t, 1, refIdsRemoved[alloc1.GetAllocationID()])
- assert.Equal(t, 1, refIdsRemoved[alloc2.GetAllocationID()])
+ assert.Equal(t, 1, refIdsRemoved[alloc1.GetAllocationKey()])
+ assert.Equal(t, 1, refIdsRemoved[alloc2.GetAllocationKey()])
}
func TestPlaceholderLargerEvent(t *testing.T) {
diff --git a/pkg/scheduler/objects/node.go b/pkg/scheduler/objects/node.go
index ecfed943..6ea167ef 100644
--- a/pkg/scheduler/objects/node.go
+++ b/pkg/scheduler/objects/node.go
@@ -204,13 +204,13 @@ func (sn *Node) refreshAvailableResource() {
}
}
-// Return the allocation based on the allocationID of the allocation.
+// Return the allocation based on the allocationKey of the allocation.
// returns nil if the allocation is not found
-func (sn *Node) GetAllocation(allocationID string) *Allocation {
+func (sn *Node) GetAllocation(allocationKey string) *Allocation {
sn.RLock()
defer sn.RUnlock()
- return sn.allocations[allocationID]
+ return sn.allocations[allocationKey]
}
// Get a copy of the allocations on this node
@@ -294,14 +294,14 @@ func (sn *Node) FitInNode(resRequest *resources.Resource)
bool {
// Returns nil if the allocation was not found and no changes are made. If the
allocation
// is found the Allocation removed is returned. Used resources will decrease
available
// will increase as per the allocation removed.
-func (sn *Node) RemoveAllocation(allocationID string) *Allocation {
+func (sn *Node) RemoveAllocation(allocationKey string) *Allocation {
defer sn.notifyListeners()
sn.Lock()
defer sn.Unlock()
- alloc := sn.allocations[allocationID]
+ alloc := sn.allocations[allocationKey]
if alloc != nil {
- delete(sn.allocations, allocationID)
+ delete(sn.allocations, allocationKey)
sn.allocatedResource.SubFrom(alloc.GetAllocatedResource())
sn.availableResource.AddTo(alloc.GetAllocatedResource())
sn.nodeEvents.sendAllocationRemovedEvent(alloc.allocationKey,
alloc.allocatedResource)
@@ -324,7 +324,7 @@ func (sn *Node) AddAllocation(alloc *Allocation) bool {
// check if this still fits: it might have changed since pre-check
res := alloc.GetAllocatedResource()
if sn.availableResource.FitIn(res) {
- sn.allocations[alloc.GetAllocationID()] = alloc
+ sn.allocations[alloc.GetAllocationKey()] = alloc
sn.allocatedResource.AddTo(res)
sn.availableResource.SubFrom(res)
sn.nodeEvents.sendAllocationAddedEvent(alloc.allocationKey, res)
@@ -336,23 +336,23 @@ func (sn *Node) AddAllocation(alloc *Allocation) bool {
// ReplaceAllocation replaces the placeholder with the real allocation on the
node.
// The delta passed in is the difference in resource usage between placeholder
and real allocation.
// It should always be a negative value or zero: it is a decrease in usage or
no change
-func (sn *Node) ReplaceAllocation(allocationID string, replace *Allocation,
delta *resources.Resource) {
+func (sn *Node) ReplaceAllocation(allocationKey string, replace *Allocation,
delta *resources.Resource) {
defer sn.notifyListeners()
sn.Lock()
defer sn.Unlock()
-
replace.SetPlaceholderCreateTime(sn.allocations[allocationID].GetCreateTime())
- delete(sn.allocations, allocationID)
+
replace.SetPlaceholderCreateTime(sn.allocations[allocationKey].GetCreateTime())
+ delete(sn.allocations, allocationKey)
replace.SetPlaceholderUsed(true)
- sn.allocations[replace.GetAllocationID()] = replace
+ sn.allocations[replace.GetAllocationKey()] = replace
before := sn.allocatedResource.Clone()
// The allocatedResource and availableResource should be updated in the
same way
sn.allocatedResource.AddTo(delta)
sn.availableResource.SubFrom(delta)
if !before.FitIn(sn.allocatedResource) {
log.Log(log.SchedNode).Warn("unexpected increase in node usage
after placeholder replacement",
- zap.String("placeholder allocationID", allocationID),
- zap.String("allocation allocationID",
replace.GetAllocationID()),
+ zap.String("placeholder allocationKey", allocationKey),
+ zap.String("allocation allocationKey",
replace.GetAllocationKey()),
zap.Stringer("delta", delta))
}
}
@@ -383,16 +383,16 @@ func (sn *Node) preReserveConditions(ask *AllocationAsk)
bool {
// run at the same time.
func (sn *Node) preConditions(ask *AllocationAsk, allocate bool) bool {
// Check the predicates plugin (k8shim)
- allocID := ask.GetAllocationKey()
+ allocationKey := ask.GetAllocationKey()
if plugin := plugins.GetResourceManagerCallbackPlugin(); plugin != nil {
// checking predicates
if err := plugin.Predicates(&si.PredicatesArgs{
- AllocationKey: allocID,
+ AllocationKey: allocationKey,
NodeID: sn.NodeID,
Allocate: allocate,
}); err != nil {
log.Log(log.SchedNode).Debug("running predicates
failed",
- zap.String("allocationKey", allocID),
+ zap.String("allocationKey", allocationKey),
zap.String("nodeID", sn.NodeID),
zap.Bool("allocateFlag", allocate),
zap.Error(err))
diff --git a/pkg/scheduler/objects/node_events.go
b/pkg/scheduler/objects/node_events.go
index 26b040c6..3a60dba4 100644
--- a/pkg/scheduler/objects/node_events.go
+++ b/pkg/scheduler/objects/node_events.go
@@ -48,20 +48,20 @@ func (n *nodeEvents) sendNodeRemovedEvent() {
n.eventSystem.AddEvent(event)
}
-func (n *nodeEvents) sendAllocationAddedEvent(allocID string, res
*resources.Resource) {
+func (n *nodeEvents) sendAllocationAddedEvent(allocKey string, res
*resources.Resource) {
if !n.eventSystem.IsEventTrackingEnabled() {
return
}
- event := events.CreateNodeEventRecord(n.node.NodeID, common.Empty,
allocID, si.EventRecord_ADD,
+ event := events.CreateNodeEventRecord(n.node.NodeID, common.Empty,
allocKey, si.EventRecord_ADD,
si.EventRecord_NODE_ALLOC, res)
n.eventSystem.AddEvent(event)
}
-func (n *nodeEvents) sendAllocationRemovedEvent(allocID string, res
*resources.Resource) {
+func (n *nodeEvents) sendAllocationRemovedEvent(allocKey string, res
*resources.Resource) {
if !n.eventSystem.IsEventTrackingEnabled() {
return
}
- event := events.CreateNodeEventRecord(n.node.NodeID, common.Empty,
allocID, si.EventRecord_REMOVE,
+ event := events.CreateNodeEventRecord(n.node.NodeID, common.Empty,
allocKey, si.EventRecord_REMOVE,
si.EventRecord_NODE_ALLOC, res)
n.eventSystem.AddEvent(event)
}
diff --git a/pkg/scheduler/objects/node_test.go
b/pkg/scheduler/objects/node_test.go
index 097cfbe0..25b32a4a 100644
--- a/pkg/scheduler/objects/node_test.go
+++ b/pkg/scheduler/objects/node_test.go
@@ -401,7 +401,7 @@ func TestAddAllocation(t *testing.T) {
half :=
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 50,
"second": 100})
alloc = newAllocation(appID1, nodeID1, half)
assert.Assert(t, node.AddAllocation(alloc), "add allocation 1 should
not have failed")
- if node.GetAllocation(alloc.GetAllocationID()) == nil {
+ if node.GetAllocation(alloc.GetAllocationKey()) == nil {
t.Fatal("failed to add allocations: allocation not returned")
}
if !resources.Equals(node.GetAllocatedResource(), half) {
@@ -418,7 +418,7 @@ func TestAddAllocation(t *testing.T) {
piece :=
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 25,
"second": 50})
alloc = newAllocation(appID1, nodeID1, piece)
assert.Assert(t, node.AddAllocation(alloc), "add allocation 2 should
not have failed")
- if node.GetAllocation(alloc.GetAllocationID()) == nil {
+ if node.GetAllocation(alloc.GetAllocationKey()) == nil {
t.Fatal("failed to add allocations: allocation not returned")
}
piece.AddTo(half)
@@ -445,7 +445,7 @@ func TestRemoveAllocation(t *testing.T) {
half :=
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 50,
"second": 100})
alloc1 := newAllocation(appID1, nodeID1, half)
node.AddAllocation(alloc1)
- if node.GetAllocation(alloc1.GetAllocationID()) == nil {
+ if node.GetAllocation(alloc1.GetAllocationKey()) == nil {
t.Fatal("failed to add allocations: allocation not returned")
}
// check empty alloc
@@ -463,10 +463,10 @@ func TestRemoveAllocation(t *testing.T) {
piece :=
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 25,
"second": 50})
alloc2 := newAllocation(appID1, nodeID1, piece)
node.AddAllocation(alloc2)
- if node.GetAllocation(alloc2.GetAllocationID()) == nil {
+ if node.GetAllocation(alloc2.GetAllocationKey()) == nil {
t.Fatal("failed to add allocations: allocation not returned")
}
- alloc := node.RemoveAllocation(alloc1.GetAllocationID())
+ alloc := node.RemoveAllocation(alloc1.GetAllocationKey())
if alloc == nil {
t.Error("allocation should have been removed but was not")
}
@@ -491,7 +491,7 @@ func TestNodeReplaceAllocation(t *testing.T) {
half :=
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 50,
"second": 100})
ph := newPlaceholderAlloc(appID1, nodeID1, half)
node.AddAllocation(ph)
- assert.Assert(t, node.GetAllocation(ph.GetAllocationID()) != nil,
"failed to add placeholder allocation")
+ assert.Assert(t, node.GetAllocation(ph.GetAllocationKey()) != nil,
"failed to add placeholder allocation")
assert.Assert(t, resources.Equals(node.GetAllocatedResource(), half),
"allocated resource not set correctly %v got %v", half,
node.GetAllocatedResource())
assert.Assert(t, resources.Equals(node.GetAvailableResource(), half),
"available resource not set correctly %v got %v", half,
node.GetAvailableResource())
@@ -501,13 +501,13 @@ func TestNodeReplaceAllocation(t *testing.T) {
delta := resources.Sub(piece, half)
assert.Assert(t, delta.HasNegativeValue(), "expected negative values in
delta")
// swap and check the calculation
- node.ReplaceAllocation(ph.GetAllocationID(), alloc, delta)
- assert.Assert(t, node.GetAllocation(alloc.GetAllocationID()) != nil,
"failed to replace allocation: allocation not returned")
+ node.ReplaceAllocation(ph.GetAllocationKey(), alloc, delta)
+ assert.Assert(t, node.GetAllocation(alloc.GetAllocationKey()) != nil,
"failed to replace allocation: allocation not returned")
assert.Assert(t, resources.Equals(node.GetAllocatedResource(), piece),
"allocated resource not set correctly %v got %v", piece,
node.GetAllocatedResource())
assert.Assert(t, resources.Equals(node.GetAvailableResource(),
resources.Sub(node.GetCapacity(), piece)), "available resource not set
correctly %v got %v", resources.Sub(node.GetCapacity(), piece),
node.GetAvailableResource())
// clean up all should be zero
- assert.Assert(t, node.RemoveAllocation(alloc.GetAllocationID()) != nil,
"allocation should have been removed but was not")
+ assert.Assert(t, node.RemoveAllocation(alloc.GetAllocationKey()) !=
nil, "allocation should have been removed but was not")
assert.Assert(t, resources.IsZero(node.GetAllocatedResource()),
"allocated resource not updated correctly")
assert.Assert(t, resources.Equals(node.GetAvailableResource(),
node.GetCapacity()), "available resource not set correctly %v got %v",
node.GetCapacity(), node.GetAvailableResource())
}
@@ -524,14 +524,14 @@ func TestGetAllocation(t *testing.T) {
}
alloc = newAllocation(appID1, nodeID1, nil)
node.AddAllocation(alloc)
- alloc = node.GetAllocation(alloc.GetAllocationID())
+ alloc = node.GetAllocation(alloc.GetAllocationKey())
if alloc == nil {
t.Fatalf("allocation should have been found")
}
// unknown allocation get a nil
alloc = node.GetAllocation("fake")
if alloc != nil {
- t.Fatalf("allocation should not have been found (fake ID)")
+ t.Fatalf("allocation should not have been found (fake key)")
}
}
@@ -683,7 +683,6 @@ func TestNodeEvents(t *testing.T) {
node.AddAllocation(&Allocation{
allocatedResource:
resources.NewResourceFromMap(map[string]resources.Quantity{"cpu": 1, "memory":
1}),
allocationKey: aKey,
- allocationID: "allocationid-0",
})
assert.Equal(t, 1, len(mockEvents.Events))
event = mockEvents.Events[0]
@@ -692,7 +691,7 @@ func TestNodeEvents(t *testing.T) {
assert.Equal(t, si.EventRecord_NODE_ALLOC, event.EventChangeDetail)
mockEvents.Reset()
- node.RemoveAllocation("allocationid-0")
+ node.RemoveAllocation(aKey)
event = mockEvents.Events[0]
assert.Equal(t, si.EventRecord_NODE, event.Type)
assert.Equal(t, si.EventRecord_REMOVE, event.EventChangeType)
diff --git a/pkg/scheduler/objects/preemption.go
b/pkg/scheduler/objects/preemption.go
index a9ca050a..efac8fa1 100644
--- a/pkg/scheduler/objects/preemption.go
+++ b/pkg/scheduler/objects/preemption.go
@@ -54,7 +54,7 @@ type Preemptor struct {
// lazily-populated work structures
allocationsByQueue map[string]*QueuePreemptionSnapshot // map of queue
snapshots by queue path
- queueByAlloc map[string]*QueuePreemptionSnapshot // map of queue
snapshots by allocationID
+ queueByAlloc map[string]*QueuePreemptionSnapshot // map of queue
snapshots by allocationKey
allocationsByNode map[string][]*Allocation // map of
allocation by nodeID
nodeAvailableMap map[string]*resources.Resource // map of
available resources by nodeID
}
@@ -144,7 +144,7 @@ func (p *Preemptor) initWorkingState() {
queueByAlloc := make(map[string]*QueuePreemptionSnapshot)
nodeAvailableMap := make(map[string]*resources.Resource)
- // build a map from NodeID to allocation and from allocationID to queue
capacities
+ // build a map from NodeID to allocation and from allocationKey to
queue capacities
for _, victims := range p.allocationsByQueue {
for _, allocation := range victims.PotentialVictims {
nodeID := allocation.GetNodeID()
diff --git a/pkg/scheduler/objects/queue_test.go
b/pkg/scheduler/objects/queue_test.go
index 6ced5642..ab38a0a0 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -2522,7 +2522,7 @@ func TestQueueRunningAppsForSingleAllocationApp(t
*testing.T) {
_, err = app.allocateAsk(ask)
assert.NilError(t, err, "failed to decrease pending resources")
- app.RemoveAllocation(alloc.GetAllocationID(),
si.TerminationType_STOPPED_BY_RM)
+ app.RemoveAllocation(alloc.GetAllocationKey(),
si.TerminationType_STOPPED_BY_RM)
assert.Equal(t, app.CurrentState(), Completing.String(), "app state
should be completing")
assert.Equal(t, leaf.runningApps, uint64(0), "leaf should have 0 app
running")
}
diff --git a/pkg/scheduler/objects/utilities_test.go
b/pkg/scheduler/objects/utilities_test.go
index 3c325046..4cab3457 100644
--- a/pkg/scheduler/objects/utilities_test.go
+++ b/pkg/scheduler/objects/utilities_test.go
@@ -36,15 +36,14 @@ import (
)
const (
- appID0 = "app-0"
- appID1 = "app-1"
- appID2 = "app-2"
- aKey = "alloc-1"
- aKey2 = "alloc-2"
- aAllocationID = "alloc-allocationid-1"
- nodeID1 = "node-1"
- nodeID2 = "node-2"
- instType1 = "itype-1"
+ appID0 = "app-0"
+ appID1 = "app-1"
+ appID2 = "app-2"
+ aKey = "alloc-1"
+ aKey2 = "alloc-2"
+ nodeID1 = "node-1"
+ nodeID2 = "node-2"
+ instType1 = "itype-1"
)
// Create the root queue, base for all testing
diff --git a/pkg/scheduler/partition.go b/pkg/scheduler/partition.go
index 3ac6a872..09d42870 100644
--- a/pkg/scheduler/partition.go
+++ b/pkg/scheduler/partition.go
@@ -391,7 +391,7 @@ func (pc *PartitionContext) removeApplication(appID string)
[]*objects.Allocatio
// track the number of allocations
pc.updateAllocationCount(-len(allocations))
for _, alloc := range allocations {
- currentAllocationID := alloc.GetAllocationID()
+ currentAllocationKey := alloc.GetAllocationKey()
node := pc.GetNode(alloc.GetNodeID())
if node == nil {
log.Log(log.SchedPartition).Warn("unknown node:
not found in active node list",
@@ -399,10 +399,10 @@ func (pc *PartitionContext) removeApplication(appID
string) []*objects.Allocatio
zap.String("nodeID", alloc.GetNodeID()))
continue
}
- if nodeAlloc :=
node.RemoveAllocation(currentAllocationID); nodeAlloc == nil {
+ if nodeAlloc :=
node.RemoveAllocation(currentAllocationKey); nodeAlloc == nil {
log.Log(log.SchedPartition).Warn("unknown
allocation: not found on the node",
zap.String("appID", appID),
- zap.String("allocationID",
currentAllocationID),
+ zap.String("allocationKey",
currentAllocationKey),
zap.String("nodeID", alloc.GetNodeID()))
}
}
@@ -690,7 +690,7 @@ func (pc *PartitionContext) removeNodeAllocations(node
*objects.Node) ([]*object
confirmed := make([]*objects.Allocation, 0)
// walk over all allocations still registered for this node
for _, alloc := range node.GetAllAllocations() {
- allocID := alloc.GetAllocationID()
+ allocationKey := alloc.GetAllocationKey()
// since we are not locking the node and or application we
could have had an update while processing
// note that we do not return the allocation if the app or
allocation is not found and assume that it
// was already removed
@@ -717,7 +717,7 @@ func (pc *PartitionContext) removeNodeAllocations(node
*objects.Node) ([]*object
// the removal of this placeholder. The ask
update will trigger rescheduling later for the real alloc.
if alloc.GetNodeID() != release.GetNodeID() {
// ignore the return as that is the
same as alloc, the alloc is gone after this call
- _ = app.ReplaceAllocation(allocID)
+ _ = app.ReplaceAllocation(allocationKey)
// we need to check the resources
equality
delta :=
resources.Sub(release.GetAllocatedResource(), alloc.GetAllocatedResource())
// Any negative value in the delta
means that at least one of the requested resource in the
@@ -730,14 +730,14 @@ func (pc *PartitionContext) removeNodeAllocations(node
*objects.Node) ([]*object
if err != nil {
log.Log(log.SchedPartition).Warn("unexpected failure during queue update:
replacing placeholder",
zap.String("appID", alloc.GetApplicationID()),
-
zap.String("placeholderID", alloc.GetAllocationID()),
-
zap.String("allocationID", release.GetAllocationID()),
+
zap.String("placeholderKey", alloc.GetAllocationKey()),
+
zap.String("allocationKey", release.GetAllocationKey()),
zap.Error(err))
}
log.Log(log.SchedPartition).Warn("replacing placeholder: placeholder is larger
than real allocation",
-
zap.String("allocationID", release.GetAllocationID()),
+
zap.String("allocationKey", release.GetAllocationKey()),
zap.Stringer("requested
resource", release.GetAllocatedResource()),
-
zap.String("placeholderID", alloc.GetAllocationID()),
+
zap.String("placeholderKey", alloc.GetAllocationKey()),
zap.Stringer("placeholder resource", alloc.GetAllocatedResource()))
}
// track what we confirm on the other
node to confirm it in the shim and get is bound
@@ -746,9 +746,9 @@ func (pc *PartitionContext) removeNodeAllocations(node
*objects.Node) ([]*object
released = append(released, alloc)
log.Log(log.SchedPartition).Info("allocation removed from node and replacement
confirmed",
zap.String("nodeID",
node.NodeID),
- zap.String("allocationID",
allocID),
+ zap.String("allocationKey",
allocationKey),
zap.String("replacement
nodeID", release.GetNodeID()),
- zap.String("replacement
allocationID", release.GetAllocationID()))
+ zap.String("replacement
allocationKey", release.GetAllocationKey()))
continue
}
askAlloc = release
@@ -763,7 +763,7 @@ func (pc *PartitionContext) removeNodeAllocations(node
*objects.Node) ([]*object
zap.String("appID",
askAlloc.GetApplicationID()),
zap.String("allocationKey",
askAlloc.GetAsk().GetAllocationKey()),
zap.String("nodeID", node.NodeID),
- zap.String("replacement allocationID",
askAlloc.GetAllocationID()))
+ zap.String("replacement allocationKey",
askAlloc.GetAllocationKey()))
} else {
log.Log(log.SchedPartition).Error("node
removal: repeat update failure for inflight replacement",
zap.String("appID",
askAlloc.GetApplicationID()),
@@ -773,9 +773,9 @@ func (pc *PartitionContext) removeNodeAllocations(node
*objects.Node) ([]*object
}
}
// check allocations on the app
- if app.RemoveAllocation(allocID,
si.TerminationType_UNKNOWN_TERMINATION_TYPE) == nil {
+ if app.RemoveAllocation(allocationKey,
si.TerminationType_UNKNOWN_TERMINATION_TYPE) == nil {
log.Log(log.SchedPartition).Info("allocation is not
found, skipping while removing the node",
- zap.String("allocationID", allocID),
+ zap.String("allocationKey", allocationKey),
zap.String("appID", app.ApplicationID),
zap.String("nodeID", node.NodeID))
continue
@@ -865,8 +865,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("allocationID", alloc.GetAllocationID()),
- zap.String("placeholder released allocationID",
alloc.GetFirstRelease().GetAllocationID()))
+ zap.String("placeholder released allocationKey",
alloc.GetFirstRelease().GetAllocationKey()))
// pass the release back to the RM via the cluster context
return alloc
}
@@ -929,7 +928,6 @@ func (pc *PartitionContext) allocate(alloc
*objects.Allocation) *objects.Allocat
log.Log(log.SchedPartition).Info("scheduler allocation processed",
zap.String("appID", alloc.GetApplicationID()),
zap.String("allocationKey", alloc.GetAllocationKey()),
- zap.String("allocationID", alloc.GetAllocationID()),
zap.Stringer("allocatedResource", alloc.GetAllocatedResource()),
zap.Bool("placeholder", alloc.IsPlaceholder()),
zap.String("targetNode", alloc.GetNodeID()))
@@ -1131,19 +1129,10 @@ func (pc *PartitionContext) addAllocation(alloc
*objects.Allocation) error {
return fmt.Errorf("partition %s is stopped cannot add new
allocation %s", pc.Name, alloc.GetAllocationKey())
}
- // We must not generate a new allocationID for it, we directly use the
allocationID reported by shim
- // to track this allocation, a missing allocationID is a broken
allocation
- if alloc.GetAllocationID() == "" {
- metrics.GetSchedulerMetrics().IncSchedulingError()
- return fmt.Errorf("failing to restore allocation %s for
application %s: missing allocationID",
- alloc.GetAllocationKey(), alloc.GetApplicationID())
- }
-
log.Log(log.SchedPartition).Info("adding recovered allocation",
zap.String("partitionName", pc.Name),
zap.String("appID", alloc.GetApplicationID()),
- zap.String("allocKey", alloc.GetAllocationKey()),
- zap.String("allocationID", alloc.GetAllocationID()))
+ zap.String("allocationKey", alloc.GetAllocationKey()))
// Check if allocation violates any resource restriction, or allocate
on a
// non-existent application or nodes.
@@ -1183,8 +1172,7 @@ func (pc *PartitionContext) addAllocation(alloc
*objects.Allocation) error {
log.Log(log.SchedPartition).Info("recovered allocation",
zap.String("partitionName", pc.Name),
zap.String("appID", alloc.GetApplicationID()),
- zap.String("allocKey", alloc.GetAllocationKey()),
- zap.String("allocationID", alloc.GetAllocationID()),
+ zap.String("allocationKey", alloc.GetAllocationKey()),
zap.Bool("placeholder", alloc.IsPlaceholder()))
return nil
}
@@ -1245,13 +1233,13 @@ func (pc *PartitionContext) removeAllocation(release
*si.AllocationRelease) ([]*
return nil, nil
}
appID := release.ApplicationID
- allocationID := release.GetAllocationID()
+ allocationKey := release.GetAllocationKey()
app := pc.getApplication(appID)
// no app nothing to do everything should already be clean
if app == nil {
log.Log(log.SchedPartition).Info("Application not found while
releasing allocation",
zap.String("appID", appID),
- zap.String("allocationID", allocationID),
+ zap.String("allocationKey", allocationKey),
zap.Stringer("terminationType",
release.TerminationType))
return nil, nil
}
@@ -1264,26 +1252,26 @@ func (pc *PartitionContext) removeAllocation(release
*si.AllocationRelease) ([]*
// temp store for allocations manipulated
released := make([]*objects.Allocation, 0)
var confirmed *objects.Allocation
- // when allocationID is not specified, remove all allocations from the
app
- if allocationID == "" {
+ // when allocationKey is not specified, remove all allocations from the
app
+ if allocationKey == "" {
log.Log(log.SchedPartition).Info("remove all allocations",
zap.String("appID", appID))
released = append(released, app.RemoveAllAllocations()...)
} else {
- // if we have an allocationID the termination type is important
+ // if we have an allocationKey the termination type is important
if release.TerminationType ==
si.TerminationType_PLACEHOLDER_REPLACED {
log.Log(log.SchedPartition).Info("replacing placeholder
allocation",
zap.String("appID", appID),
- zap.String("allocationID", allocationID))
- if alloc := app.ReplaceAllocation(allocationID); alloc
!= nil {
+ zap.String("allocationKey", allocationKey))
+ if alloc := app.ReplaceAllocation(allocationKey); alloc
!= nil {
released = append(released, alloc)
}
} else {
log.Log(log.SchedPartition).Info("removing allocation
from application",
zap.String("appID", appID),
- zap.String("allocationID", allocationID),
+ zap.String("allocationKey", allocationKey),
zap.Stringer("terminationType",
release.TerminationType))
- if alloc := app.RemoveAllocation(allocationID,
release.TerminationType); alloc != nil {
+ if alloc := app.RemoveAllocation(allocationKey,
release.TerminationType); alloc != nil {
released = append(released, alloc)
}
}
@@ -1309,7 +1297,7 @@ func (pc *PartitionContext) removeAllocation(release
*si.AllocationRelease) ([]*
if node == nil {
log.Log(log.SchedPartition).Warn("node not found while
releasing allocation",
zap.String("appID", appID),
- zap.String("allocationID",
alloc.GetAllocationID()),
+ zap.String("allocationKey",
alloc.GetAllocationKey()),
zap.String("nodeID", alloc.GetNodeID()))
continue
}
@@ -1325,29 +1313,29 @@ func (pc *PartitionContext) removeAllocation(release
*si.AllocationRelease) ([]*
// total tracked. The total will later be
deducted from the queue usage.
total.SubFrom(delta)
log.Log(log.SchedPartition).Warn("replacing
placeholder: placeholder is larger than real allocation",
- zap.String("allocationID",
confirmed.GetAllocationID()),
+ zap.String("allocationKey",
confirmed.GetAllocationKey()),
zap.Stringer("requested resource",
confirmed.GetAllocatedResource()),
- zap.String("placeholderID",
alloc.GetAllocationID()),
+ zap.String("placeholderKey",
alloc.GetAllocationKey()),
zap.Stringer("placeholder resource",
alloc.GetAllocatedResource()))
}
// replacements could be on a different node and
different size handle all cases
if confirmed.GetNodeID() == alloc.GetNodeID() {
// this is the real swap on the node, adjust
usage if needed
- node.ReplaceAllocation(alloc.GetAllocationID(),
confirmed, delta)
+
node.ReplaceAllocation(alloc.GetAllocationKey(), confirmed, delta)
} else {
// we have already added the real allocation to
the new node, just remove the placeholder
- node.RemoveAllocation(alloc.GetAllocationID())
+ node.RemoveAllocation(alloc.GetAllocationKey())
}
log.Log(log.SchedPartition).Info("replacing placeholder
allocation on node",
zap.String("nodeID", alloc.GetNodeID()),
- zap.String("allocationID",
alloc.GetAllocationID()),
+ zap.String("allocationKey",
alloc.GetAllocationKey()),
zap.String("allocation nodeID",
confirmed.GetNodeID()))
- } else if node.RemoveAllocation(alloc.GetAllocationID()) != nil
{
+ } else if node.RemoveAllocation(alloc.GetAllocationKey()) !=
nil {
// all non replacement are real removes: must update
the queue usage
total.AddTo(alloc.GetAllocatedResource())
log.Log(log.SchedPartition).Info("removing allocation
from node",
zap.String("nodeID", alloc.GetNodeID()),
- zap.String("allocationID",
alloc.GetAllocationID()))
+ zap.String("allocationKey",
alloc.GetAllocationKey()))
}
if alloc.IsPreempted() {
totalPreempting.AddTo(alloc.GetAllocatedResource())
@@ -1357,7 +1345,7 @@ func (pc *PartitionContext) removeAllocation(release
*si.AllocationRelease) ([]*
if err := queue.DecAllocatedResource(total); err != nil {
log.Log(log.SchedPartition).Warn("failed to release
resources from queue",
zap.String("appID", appID),
- zap.String("allocationID", allocationID),
+ zap.String("allocationKey", allocationKey),
zap.Error(err))
}
}
diff --git a/pkg/scheduler/partition_test.go b/pkg/scheduler/partition_test.go
index 00a980a4..dffae4e6 100644
--- a/pkg/scheduler/partition_test.go
+++ b/pkg/scheduler/partition_test.go
@@ -244,7 +244,7 @@ func TestAddNodeWithAllocations(t *testing.T) {
node := newNodeMaxResource(nodeID1, nodeRes)
// fail with an unknown app
- ask := newAllocationAsk("alloc-1-allocationid", "unknown", appRes)
+ ask := newAllocationAsk("alloc-1", "unknown", appRes)
alloc := objects.NewAllocation(nodeID1, ask)
allocs := []*objects.Allocation{alloc}
err = partition.AddNode(node, allocs)
@@ -254,21 +254,7 @@ func TestAddNodeWithAllocations(t *testing.T) {
assert.Equal(t, partition.nodes.GetNodeCount(), 0, "error returned but
node still added to the partition (app)")
// fail with a broken alloc
- ask = newAllocationAsk("alloc-1-allocationid", appID1, appRes)
- alloc = objects.NewAllocation(nodeID1, ask)
- assert.Equal(t, alloc.GetAllocationID(), "alloc-1-allocationid")
- // reset allocationID to empty
- alloc.SetAllocationID("")
- assert.Equal(t, alloc.GetAllocationID(), "")
- allocs = []*objects.Allocation{alloc}
- err = partition.AddNode(node, allocs)
- if err == nil {
- t.Errorf("add node to partition should have failed
(allocationID missing)")
- }
- assert.Equal(t, partition.nodes.GetNodeCount(), 0, "error returned but
node still added to the partition (allocationID)")
- assertLimits(t, getTestUserGroup(), nil)
-
- // fix the alloc add the node will work now
+ ask = newAllocationAsk("alloc-1", appID1, appRes)
alloc = objects.NewAllocation(nodeID1, ask)
allocs = []*objects.Allocation{alloc}
// add a node this must work
@@ -318,7 +304,7 @@ func TestRemoveNodeWithAllocations(t *testing.T) {
appRes :=
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 1000})
ask := newAllocationAsk("alloc-1", appID1, appRes)
alloc := objects.NewAllocation(nodeID1, ask)
- allocAllocationID := alloc.GetAllocationID()
+ allocAllocationKey := alloc.GetAllocationKey()
allocs := []*objects.Allocation{alloc}
err = partition.AddNode(node, allocs)
assert.NilError(t, err, "add node to partition should not have failed")
@@ -341,7 +327,7 @@ func TestRemoveNodeWithAllocations(t *testing.T) {
assert.Equal(t, 0, partition.GetTotalNodeCount(), "node list was not
updated, node was not removed")
assert.Equal(t, 1, len(released), "node did not release correct
allocation")
assert.Equal(t, 0, len(confirmed), "node did not confirm correct
allocation")
- assert.Equal(t, released[0].GetAllocationID(), allocAllocationID,
"allocationID returned by release not the same as on allocation")
+ assert.Equal(t, released[0].GetAllocationKey(), allocAllocationKey,
"allocationKey returned by release not the same as on allocation")
assertLimits(t, getTestUserGroup(), resources.Zero)
assert.NilError(t, err, "the event should have been processed")
@@ -375,10 +361,10 @@ func TestRemoveNodeWithPlaceholders(t *testing.T) {
assert.Equal(t, 1, partition.getPhAllocationCount(), "number of active
placeholders")
// fake an ask that is used
- ask = newAllocationAskAll(allocID, appID1, taskGroup, appRes, 1, false)
+ ask = newAllocationAskAll(allocKey, appID1, taskGroup, appRes, 1, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "ask should be added to app")
- _, err = app.AllocateAsk(allocID)
+ _, err = app.AllocateAsk(allocKey)
assert.NilError(t, err, "ask should have been updated without error")
assert.Assert(t, resources.IsZero(app.GetPendingResource()), "app
should not have pending resources")
assertLimits(t, getTestUserGroup(), appRes)
@@ -399,7 +385,7 @@ func TestRemoveNodeWithPlaceholders(t *testing.T) {
assert.Equal(t, 0, partition.GetTotalNodeCount(), "node list was not
updated, node was not removed")
assert.Equal(t, 1, len(released), "node removal did not release correct
allocation")
assert.Equal(t, 0, len(confirmed), "node removal should not have
confirmed allocation")
- assert.Equal(t, ph.GetAllocationID(), released[0].GetAllocationID(),
"allocationID returned by release not the same as the placeholder")
+ assert.Equal(t, ph.GetAllocationKey(), released[0].GetAllocationKey(),
"allocationKey returned by release not the same as the placeholder")
assert.Equal(t, 0, partition.getPhAllocationCount(), "number of active
placeholders")
allocs = app.GetAllAllocations()
assert.Equal(t, 0, len(allocs), "expected no allocations for the app")
@@ -519,7 +505,7 @@ func TestPlaceholderDataWithPlaceholderPreemption(t
*testing.T) {
assert.NilError(t, err, "add application to partition should not have
failed")
// required node set on ask
- ask2 := newAllocationAsk(allocID2, appID3, res)
+ ask2 := newAllocationAsk(allocKey2, appID3, res)
ask2.SetRequiredNode(nodeID2)
err = app2.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask alloc-2 to app1-1")
@@ -531,7 +517,7 @@ func TestPlaceholderDataWithPlaceholderPreemption(t
*testing.T) {
}
// check if updated (must be after allocate call)
assert.Equal(t, 1, len(app2.GetReservations()), "app reservation should
have been updated")
- assert.Equal(t, 1, len(app2.GetAskReservations(allocID2)), "ask should
have been reserved")
+ assert.Equal(t, 1, len(app2.GetAskReservations(allocKey2)), "ask should
have been reserved")
// try through reserved scheduling cycle this should trigger preemption
alloc = partition.tryReservedAllocate()
@@ -541,11 +527,11 @@ func TestPlaceholderDataWithPlaceholderPreemption(t
*testing.T) {
// check if there is a release event for the expected allocation
var found bool
- var releasedAllocationID string
+ var releasedAllocationKey string
for _, event := range testHandler2.GetEvents() {
if allocRelease, ok :=
event.(*rmevent.RMReleaseAllocationEvent); ok {
found =
allocRelease.ReleasedAllocations[0].AllocationKey == lastPh
- releasedAllocationID =
allocRelease.ReleasedAllocations[0].AllocationID
+ releasedAllocationKey =
allocRelease.ReleasedAllocations[0].AllocationKey
break
}
}
@@ -554,7 +540,7 @@ func TestPlaceholderDataWithPlaceholderPreemption(t
*testing.T) {
release := &si.AllocationRelease{
PartitionName: partition.Name,
ApplicationID: appID2,
- AllocationID: releasedAllocationID,
+ AllocationKey: releasedAllocationKey,
TerminationType: si.TerminationType_PREEMPTED_BY_SCHEDULER,
}
releases, confirmed := partition.removeAllocation(release)
@@ -703,7 +689,7 @@ func TestPlaceholderDataWithRemoval(t *testing.T) {
err = partition.AddApplication(gangApp)
assert.NilError(t, err, "app1-1 should have been added to the
partition")
- var lastPhAllocationID string
+ var lastPhAllocationKey string
for i := 1; i <= 6; i++ {
// add an ask for a placeholder and allocate
ask = newAllocationAskTG(phID+strconv.Itoa(i+1), appID2,
taskGroup, res, true)
@@ -714,7 +700,7 @@ func TestPlaceholderDataWithRemoval(t *testing.T) {
if ph == nil {
t.Fatal("expected placeholder to be allocated")
}
- lastPhAllocationID = ph.GetAllocationID()
+ lastPhAllocationKey = ph.GetAllocationKey()
}
// add an ask for a last placeholder and allocate
@@ -731,7 +717,7 @@ func TestPlaceholderDataWithRemoval(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: partition.Name,
ApplicationID: appID2,
- AllocationID: lastPhAllocationID,
+ AllocationKey: lastPhAllocationKey,
TerminationType: si.TerminationType_STOPPED_BY_RM,
}
releases, _ := partition.removeAllocation(release)
@@ -778,10 +764,10 @@ func TestRemoveNodeWithReplacement(t *testing.T) {
assert.Equal(t, 2, partition.GetTotalNodeCount(), "node list was not
updated as expected")
// fake an ask that is used
- ask = newAllocationAskAll(allocID, appID1, taskGroup, appRes, 1, false)
+ ask = newAllocationAskAll(allocKey, appID1, taskGroup, appRes, 1, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "ask should be added to app")
- _, err = app.AllocateAsk(allocID)
+ _, err = app.AllocateAsk(allocKey)
assert.NilError(t, err, "ask should have been updated without error")
assert.Assert(t, resources.IsZero(app.GetPendingResource()), "app
should not have pending resources")
@@ -808,13 +794,13 @@ func TestRemoveNodeWithReplacement(t *testing.T) {
assert.Equal(t, 1, len(node2.GetAllAllocations()), "remaining node
should have allocation")
assert.Equal(t, 1, len(released), "node removal did not release correct
allocation")
assert.Equal(t, 1, len(confirmed), "node removal did not confirm
correct allocation")
- assert.Equal(t, ph.GetAllocationID(), released[0].GetAllocationID(),
"allocationID returned by release not the same as the placeholder")
- assert.Equal(t, alloc.GetAllocationID(),
confirmed[0].GetAllocationID(), "allocationID returned by confirmed not the
same as the real allocation")
+ assert.Equal(t, ph.GetAllocationKey(), released[0].GetAllocationKey(),
"allocationKey returned by release not the same as the placeholder")
+ assert.Equal(t, alloc.GetAllocationKey(),
confirmed[0].GetAllocationKey(), "allocationKey returned by confirmed not the
same as the real allocation")
assert.Assert(t, resources.IsZero(app.GetPendingResource()), "app
should not have pending resources")
assert.Assert(t, !app.IsCompleting(), "app should not be COMPLETING
after confirming allocation")
allocs = app.GetAllAllocations()
assert.Equal(t, 1, len(allocs), "expected one allocation for the app
(real)")
- assert.Equal(t, alloc.GetAllocationID(), allocs[0].GetAllocationID(),
"allocationID for the app is not the same as the real allocation")
+ 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")
assertLimits(t, getTestUserGroup(), appRes)
@@ -850,10 +836,10 @@ func TestRemoveNodeWithReal(t *testing.T) {
assert.Equal(t, 2, partition.GetTotalNodeCount(), "node list was not
updated as expected")
// fake an ask that is used
- ask = newAllocationAskAll(allocID, appID1, taskGroup, appRes, 1, false)
+ ask = newAllocationAskAll(allocKey, appID1, taskGroup, appRes, 1, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "ask should be added to app")
- _, err = app.AllocateAsk(allocID)
+ _, err = app.AllocateAsk(allocKey)
assert.NilError(t, err, "ask should have been updated without error")
assert.Assert(t, resources.IsZero(app.GetPendingResource()), "app
should not have pending resources")
@@ -881,7 +867,7 @@ func TestRemoveNodeWithReal(t *testing.T) {
assert.Assert(t, resources.Equals(app.GetPendingResource(), appRes),
"app should have updated pending resources")
allocs = app.GetAllAllocations()
assert.Equal(t, 1, len(allocs), "expected one allocation for the app
(placeholder")
- assert.Equal(t, ph.GetAllocationID(), allocs[0].GetAllocationID(),
"allocationID for the app is not the same as the real allocation")
+ 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")
assertLimits(t, getTestUserGroup(), appRes)
}
@@ -1143,7 +1129,7 @@ func TestRemoveAppAllocs(t *testing.T) {
assertLimits(t, getTestUserGroup(), appRes)
ask = newAllocationAsk("alloc-1", appNotRemoved, appRes)
- allocationID := "alloc-1"
+ allocationKey := "alloc-1"
alloc = objects.NewAllocation(nodeID1, ask)
err = partition.addAllocation(alloc)
assert.NilError(t, err, "add allocation to partition should not have
failed")
@@ -1151,7 +1137,7 @@ func TestRemoveAppAllocs(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: "default",
ApplicationID: "",
- AllocationID: "",
+ AllocationKey: "",
TerminationType: si.TerminationType_STOPPED_BY_RM,
}
@@ -1165,19 +1151,19 @@ func TestRemoveAppAllocs(t *testing.T) {
assertLimits(t, getTestUserGroup(), resources.Multiply(appRes, 2))
// create a new release with app, non existing allocation: should just
return
release.ApplicationID = appNotRemoved
- release.AllocationID = "does_not_exist"
+ release.AllocationKey = "does_not_exist"
allocs, _ = partition.removeAllocation(release)
assert.Equal(t, 0, len(allocs), "removal request for non existing
allocation returned allocations: %v", allocs)
assertLimits(t, getTestUserGroup(), resources.Multiply(appRes, 2))
// create a new release with app, existing allocation: should return 1
alloc
assert.Equal(t, 2, partition.GetTotalAllocationCount(), "pre-remove
allocation list incorrect: %v", partition.allocations)
- release.AllocationID = allocationID
+ release.AllocationKey = allocationKey
allocs, _ = partition.removeAllocation(release)
assert.Equal(t, 1, len(allocs), "removal request for existing
allocation returned wrong allocations: %v", allocs)
assert.Equal(t, 1, partition.GetTotalAllocationCount(), "allocation
removal requests removed more than expected: %v", partition.allocations)
assertLimits(t, getTestUserGroup(), resources.Multiply(appRes, 1))
- // create a new release with app, no allocationID: should return last
left alloc
- release.AllocationID = ""
+ // create a new release with app, no allocationKey: should return last
left alloc
+ release.AllocationKey = ""
allocs, _ = partition.removeAllocation(release)
assert.Equal(t, 1, len(allocs), "removal request for existing
allocation returned wrong allocations: %v", allocs)
assert.Equal(t, 0, partition.GetTotalAllocationCount(), "removal
requests did not remove all allocations: %v", partition.allocations)
@@ -1208,7 +1194,7 @@ func TestRemoveAllPlaceholderAllocs(t *testing.T) {
partition.removeAllocation(&si.AllocationRelease{
PartitionName: "default",
ApplicationID: appID1,
- AllocationID: "",
+ AllocationKey: "",
TerminationType: si.TerminationType_STOPPED_BY_RM,
})
assert.Equal(t, 0, partition.getPhAllocationCount())
@@ -1549,7 +1535,7 @@ func TestTryAllocate(t *testing.T) {
// add to the partition
err = partition.AddApplication(app)
assert.NilError(t, err, "failed to add app-1 to partition")
- err = app.AddAllocationAsk(newAllocationAsk(allocID, appID1, res))
+ err = app.AddAllocationAsk(newAllocationAsk(allocKey, appID1, res))
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
err = app.AddAllocationAsk(newAllocationAskPriority("alloc-2", appID1,
res, 2))
assert.NilError(t, err, "failed to add ask alloc-2 to app-1")
@@ -1558,7 +1544,7 @@ func TestTryAllocate(t *testing.T) {
// add to the partition
err = partition.AddApplication(app)
assert.NilError(t, err, "failed to add app-2 to partition")
- err = app.AddAllocationAsk(newAllocationAskPriority(allocID, appID2,
res, 2))
+ err = app.AddAllocationAsk(newAllocationAskPriority(allocKey, appID2,
res, 2))
assert.NilError(t, err, "failed to add ask alloc-1 to app-2")
expectedQueuesMaxLimits := make(map[string]map[string]interface{})
@@ -1578,7 +1564,7 @@ func TestTryAllocate(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID1, "expected application
app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID2, "expected ask
alloc-2 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey2, "expected ask
alloc-2 to be allocated")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.Multiply(res, 1), expectedQueuesMaxLimits)
// second allocation should be app-2 and alloc-1: higher up in the
queue hierarchy
@@ -1589,7 +1575,7 @@ func TestTryAllocate(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID2, "expected application
app-2 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask
alloc-1 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask
alloc-1 to be allocated")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.Multiply(res, 2), expectedQueuesMaxLimits)
// third allocation should be app-1 and alloc-1
@@ -1600,7 +1586,7 @@ func TestTryAllocate(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID1, "expected application
app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask
alloc-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")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.Multiply(res, 3), expectedQueuesMaxLimits)
}
@@ -1623,7 +1609,7 @@ func TestRequiredNodeReservation(t *testing.T) {
// add to the partition
err = partition.AddApplication(app)
assert.NilError(t, err, "failed to add app-1 to partition")
- ask := newAllocationAsk(allocID, appID1, res)
+ ask := newAllocationAsk(allocKey, appID1, res)
ask.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
@@ -1637,10 +1623,10 @@ func TestRequiredNodeReservation(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID1, "expected application
app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask
alloc-1 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask
alloc-1 to be allocated")
assertLimits(t, getTestUserGroup(), res)
- ask2 := newAllocationAsk(allocID2, appID1, res)
+ ask2 := newAllocationAsk(allocKey2, appID1, res)
ask2.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask alloc-2 to app-1")
@@ -1650,7 +1636,7 @@ func TestRequiredNodeReservation(t *testing.T) {
}
// check if updated (must be after allocate call)
assert.Equal(t, 1, len(app.GetReservations()), "app should have one
reserved ask")
- assert.Equal(t, 1, len(app.GetAskReservations(allocID2)), "ask should
have been reserved")
+ assert.Equal(t, 1, len(app.GetAskReservations(allocKey2)), "ask should
have been reserved")
assertLimits(t, getTestUserGroup(), res)
// allocation that fits on the node should not be allocated
@@ -1847,7 +1833,7 @@ func TestRequiredNodeNotExist(t *testing.T) {
var res *resources.Resource
res, err = resources.NewResourceFromConf(map[string]string{"vcore":
"1"})
assert.NilError(t, err, "failed to create resource")
- ask := newAllocationAsk(allocID, appID1, res)
+ ask := newAllocationAsk(allocKey, appID1, res)
ask.SetRequiredNode("unknown")
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
@@ -1884,7 +1870,7 @@ func TestRequiredNodeAllocation(t *testing.T) {
assert.NilError(t, err, "failed to add app-1 to partition")
// normal ask
- ask := newAllocationAsk(allocID, appID1, res)
+ ask := newAllocationAsk(allocKey, appID1, res)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
@@ -1896,11 +1882,11 @@ func TestRequiredNodeAllocation(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID1, "expected application
app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask
alloc-1 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask
alloc-1 to be allocated")
assertLimits(t, getTestUserGroup(), res)
// required node set on ask
- ask2 := newAllocationAsk(allocID2, appID1, res)
+ ask2 := newAllocationAsk(allocKey2, appID1, res)
ask2.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask alloc-2 to app-1")
@@ -1912,7 +1898,7 @@ func TestRequiredNodeAllocation(t *testing.T) {
}
// ensure there is no reservations
assert.Equal(t, 0, len(app.GetReservations()), "ask should not have
been reserved")
- assert.Equal(t, alloc.GetAllocationKey(), allocID2, "expected ask
alloc-2 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey2, "expected ask
alloc-2 to be allocated")
assert.Equal(t, alloc.GetResult(), objects.Allocated, "result is not
the expected allocated")
assertLimits(t, getTestUserGroup(), resources.Multiply(res, 2))
}
@@ -1944,7 +1930,7 @@ func TestPreemption(t *testing.T) {
assert.NilError(t, err, "failed to create resource")
// ask 3
- ask3 := newAllocationAskPreempt(allocID3, appID2, 1, res)
+ ask3 := newAllocationAskPreempt(allocKey3, appID2, 1, res)
err = app2.AddAllocationAsk(ask3)
assert.NilError(t, err, "failed to add ask alloc-3 to app-2")
@@ -1977,10 +1963,9 @@ func TestPreemption(t *testing.T) {
partition.removeAllocation(&si.AllocationRelease{
PartitionName: "default",
ApplicationID: appID1,
- AllocationID: alloc2.GetAllocationID(),
+ AllocationKey: alloc2.GetAllocationKey(),
TerminationType: si.TerminationType_STOPPED_BY_RM,
Message: "Preempted",
- AllocationKey: allocID2,
})
// currently preempting resources in victim queue should be zero
@@ -1994,7 +1979,7 @@ func TestPreemption(t *testing.T) {
}
assert.Equal(t, 0, len(app2.GetReservations()), "ask should not be
reserved")
assert.Equal(t, alloc.GetResult(), objects.AllocatedReserved, "result
should be allocated from reservation")
- assert.Equal(t, alloc.GetAllocationKey(), allocID3, "expected ask
alloc-3 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey3, "expected ask
alloc-3 to be allocated")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 10000}),
getExpectedQueuesLimitsForPreemption())
appSummary := app1.GetApplicationSummary("default")
@@ -2032,7 +2017,7 @@ func TestPreemptionForRequiredNodeReservedAlloc(t
*testing.T) {
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.Equal(t, alloc.GetAllocationKey(), allocID2, "expected ask
alloc-2 to be allocated")
+ 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())
}
@@ -2051,7 +2036,7 @@ func
TestPreemptionForRequiredNodeMultipleAttemptsAvoided(t *testing.T) {
assert.NilError(t, err, "failed to add app-1 to partition")
// normal ask
- ask := newAllocationAsk(allocID, appID1, res)
+ ask := newAllocationAsk(allocKey, appID1, res)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
@@ -2059,7 +2044,7 @@ func
TestPreemptionForRequiredNodeMultipleAttemptsAvoided(t *testing.T) {
alloc := partition.tryAllocate()
// required node set on ask
- ask2 := newAllocationAsk(allocID2, appID1, res)
+ ask2 := newAllocationAsk(allocKey2, appID1, res)
ask2.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask alloc-2 to app-1")
@@ -2074,7 +2059,7 @@ func
TestPreemptionForRequiredNodeMultipleAttemptsAvoided(t *testing.T) {
var eventCount int
for _, event := range testHandler.GetEvents() {
if allocRelease, ok :=
event.(*rmevent.RMReleaseAllocationEvent); ok {
- if allocRelease.ReleasedAllocations[0].AllocationKey ==
allocID {
+ if allocRelease.ReleasedAllocations[0].AllocationKey ==
allocKey {
eventCount++
}
}
@@ -2134,7 +2119,7 @@ func setupPreemption(t *testing.T) (*PartitionContext,
*objects.Application, *ob
assert.NilError(t, err, "failed to add app-1 to partition")
// ask 1
- ask := newAllocationAskPreempt(allocID, appID1, 2, res)
+ ask := newAllocationAskPreempt(allocKey, appID1, 2, res)
err = app1.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
@@ -2146,13 +2131,13 @@ func setupPreemption(t *testing.T) (*PartitionContext,
*objects.Application, *ob
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.Equal(t, alloc1.GetApplicationID(), appID1, "expected
application app-1 to be allocated")
- assert.Equal(t, alloc1.GetAllocationKey(), allocID, "expected ask
alloc-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")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 5000}),
getExpectedQueuesLimitsForPreemption())
// ask 2
- ask2 := newAllocationAskPreempt(allocID2, appID1, 1, res)
+ ask2 := newAllocationAskPreempt(allocKey2, appID1, 1, res)
err = app1.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask alloc-2 to app-1")
@@ -2164,7 +2149,7 @@ func setupPreemption(t *testing.T) (*PartitionContext,
*objects.Application, *ob
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.Equal(t, alloc2.GetApplicationID(), appID1, "expected
application app-1 to be allocated")
- assert.Equal(t, alloc2.GetAllocationKey(), allocID2, "expected ask
alloc-2 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")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 10000}),
getExpectedQueuesLimitsForPreemption())
@@ -2196,7 +2181,7 @@ func setupPreemptionForRequiredNode(t *testing.T)
(*PartitionContext, *objects.A
assert.NilError(t, err, "failed to add app-1 to partition")
// normal ask
- ask := newAllocationAsk(allocID, appID1, res)
+ ask := newAllocationAsk(allocKey, appID1, res)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
@@ -2208,12 +2193,12 @@ func setupPreemptionForRequiredNode(t *testing.T)
(*PartitionContext, *objects.A
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.Equal(t, alloc.GetApplicationID(), appID1, "expected application
app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask
alloc-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())
- allocationID := alloc.GetAllocationID()
+ allocationKey := alloc.GetAllocationKey()
// required node set on ask
- ask2 := newAllocationAsk(allocID2, appID1, res)
+ ask2 := newAllocationAsk(allocKey2, appID1, res)
ask2.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask alloc-2 to app-1")
@@ -2225,7 +2210,7 @@ func setupPreemptionForRequiredNode(t *testing.T)
(*PartitionContext, *objects.A
}
// check if updated (must be after allocate call)
assert.Equal(t, 1, len(app.GetReservations()), "ask should have been
reserved")
- assert.Equal(t, 1, len(app.GetAskReservations(allocID2)), "ask should
have been reserved")
+ assert.Equal(t, 1, len(app.GetAskReservations(allocKey2)), "ask should
have been reserved")
assertUserGroupResourceMaxLimits(t, getTestUserGroup(),
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 8000}),
getExpectedQueuesLimitsForPreemptionWithRequiredNode())
// try through reserved scheduling cycle this should trigger preemption
@@ -2238,7 +2223,7 @@ func setupPreemptionForRequiredNode(t *testing.T)
(*PartitionContext, *objects.A
var found bool
for _, event := range testHandler.GetEvents() {
if allocRelease, ok :=
event.(*rmevent.RMReleaseAllocationEvent); ok {
- found =
allocRelease.ReleasedAllocations[0].AllocationKey == allocID
+ found =
allocRelease.ReleasedAllocations[0].AllocationKey == allocKey
break
}
}
@@ -2247,7 +2232,7 @@ func setupPreemptionForRequiredNode(t *testing.T)
(*PartitionContext, *objects.A
release := &si.AllocationRelease{
PartitionName: partition.Name,
ApplicationID: appID1,
- AllocationID: allocationID,
+ AllocationKey: allocationKey,
TerminationType: si.TerminationType_PREEMPTED_BY_SCHEDULER,
}
releases, _ := partition.removeAllocation(release)
@@ -2951,7 +2936,7 @@ func TestPlaceholderSmallerThanReal(t *testing.T) {
assertLimits(t, getTestUserGroup(), phRes)
// add an ask which is larger than the placeholder
- ask = newAllocationAskTG(allocID, appID1, taskGroup, tgRes, false)
+ ask = newAllocationAskTG(allocKey, appID1, taskGroup, tgRes, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app with correct
TG")
// allocate should trigger release of placeholder nothing else
@@ -2965,7 +2950,7 @@ func TestPlaceholderSmallerThanReal(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: ph.GetPartitionName(),
ApplicationID: appID1,
- AllocationID: ph.GetAllocationID(),
+ AllocationKey: ph.GetAllocationKey(),
TerminationType: si.TerminationType_TIMEOUT,
}
assert.Equal(t, 1, partition.getPhAllocationCount(), "ph should be
registered")
@@ -3019,7 +3004,7 @@ func TestPlaceholderSmallerMulti(t *testing.T) {
assertLimits(t, getTestUserGroup(), tgRes)
// add an ask which is larger than the placeholder
- ask := newAllocationAskTG(allocID, appID1, taskGroup, tgRes, false)
+ ask := newAllocationAskTG(allocKey, appID1, taskGroup, tgRes, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app with correct
TG")
// allocate should trigger release of placeholder nothing else
@@ -3037,7 +3022,7 @@ func TestPlaceholderSmallerMulti(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: ph.GetPartitionName(),
ApplicationID: appID1,
- AllocationID: ph.GetAllocationID(),
+ AllocationKey: ph.GetAllocationKey(),
TerminationType: si.TerminationType_TIMEOUT,
}
released, _ := partition.removeAllocation(release)
@@ -3086,7 +3071,7 @@ func TestPlaceholderBiggerThanReal(t *testing.T) {
assertLimits(t, getTestUserGroup(), phRes)
// add a new ask with smaller request and allocate
- ask = newAllocationAskTG(allocID, appID1, taskGroup, smallRes, false)
+ ask = newAllocationAskTG(allocKey, appID1, taskGroup, smallRes, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app with correct
TG")
alloc := partition.tryPlaceholderAllocate()
@@ -3104,7 +3089,7 @@ func TestPlaceholderBiggerThanReal(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: ph.GetPartitionName(),
ApplicationID: appID1,
- AllocationID: ph.GetAllocationID(),
+ AllocationKey: ph.GetAllocationKey(),
TerminationType: si.TerminationType_PLACEHOLDER_REPLACED,
}
released, confirmed := partition.removeAllocation(release)
@@ -3143,7 +3128,7 @@ func TestPlaceholderMatch(t *testing.T) {
if ph == nil {
t.Fatal("expected placeholder ph-1 to be allocated")
}
- phAllocationID := ph.GetAllocationID()
+ phAllocationKey := ph.GetAllocationKey()
assert.Equal(t, phID, ph.GetAllocationKey(), "expected allocation of
ph-1 to be returned")
assert.Equal(t, 1, len(app.GetAllPlaceholderData()), "placeholder data
should be created on allocate")
assert.Equal(t, 1, partition.GetTotalAllocationCount(), "placeholder
allocation should be registered as allocation")
@@ -3151,7 +3136,7 @@ func TestPlaceholderMatch(t *testing.T) {
assertLimits(t, getTestUserGroup(), phRes)
// add a new ask with an unknown task group (should allocate directly)
- ask = newAllocationAskTG(allocID, appID1, "unknown", phRes, false)
+ ask = newAllocationAskTG(allocKey, appID1, "unknown", phRes, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-2 to app")
alloc := partition.tryAllocate()
@@ -3160,14 +3145,14 @@ func TestPlaceholderMatch(t *testing.T) {
}
assert.Equal(t, 2, partition.GetTotalAllocationCount(), "allocations
should be registered: ph + normal")
assert.Equal(t, 1, partition.getPhAllocationCount(), "placeholder
allocation should be registered")
- assert.Equal(t, allocID, alloc.GetAllocationKey(), "expected allocation
of alloc-1 to be returned")
+ assert.Equal(t, allocKey, alloc.GetAllocationKey(), "expected
allocation of alloc-1 to be returned")
assert.Equal(t, 1, len(app.GetAllPlaceholderData()), "placeholder data
should not be updated")
assert.Equal(t, int64(1), app.GetAllPlaceholderData()[0].Count,
"placeholder data should show 1 available placeholder")
assert.Equal(t, int64(0), app.GetAllPlaceholderData()[0].Replaced,
"placeholder data should show no replacements")
assertLimits(t, getTestUserGroup(), resources.Multiply(phRes, 2))
// add a new ask the same task group as the placeholder
- ask = newAllocationAskTG(allocID2, appID1, taskGroup, phRes, false)
+ ask = newAllocationAskTG(allocKey2, appID1, taskGroup, phRes, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-2 to app")
alloc = partition.tryAllocate()
@@ -3186,7 +3171,7 @@ func TestPlaceholderMatch(t *testing.T) {
}
assert.Equal(t, 2, partition.GetTotalAllocationCount(), "allocations
should be registered: ph + normal")
assert.Equal(t, 1, partition.getPhAllocationCount(), "placeholder
allocation should be registered")
- assert.Equal(t, allocID2, alloc.GetAllocationKey(), "expected
allocation of alloc-2 to be returned")
+ assert.Equal(t, allocKey2, alloc.GetAllocationKey(), "expected
allocation of alloc-2 to be returned")
assert.Equal(t, int64(1), app.GetAllPlaceholderData()[0].Count,
"placeholder data should show 1 available placeholder")
assert.Equal(t, int64(0), app.GetAllPlaceholderData()[0].Replaced,
"placeholder data should show no replacements yet")
@@ -3194,7 +3179,7 @@ func TestPlaceholderMatch(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: "test",
ApplicationID: appID1,
- AllocationID: phAllocationID,
+ AllocationKey: phAllocationKey,
TerminationType: si.TerminationType_PLACEHOLDER_REPLACED,
}
released, confirmed := partition.removeAllocation(release)
@@ -3244,14 +3229,14 @@ func TestPreemptedPlaceholderSkip(t *testing.T) {
if ph == nil {
t.Fatal("expected placeholder ph-1 to be allocated")
}
- phAllocationID := ph.GetAllocationID()
+ phAllocationKey := ph.GetAllocationKey()
assert.Equal(t, phID, ph.GetAllocationKey(), "expected allocation of
ph-1 to be returned")
assert.Equal(t, 1, len(app.GetAllPlaceholderData()), "placeholder data
should be created on allocate")
assert.Equal(t, 1, partition.GetTotalAllocationCount(), "placeholder
allocation should be registered as allocation")
assert.Equal(t, 1, partition.getPhAllocationCount(), "placeholder
allocation should be registered")
// add a new ask the same task group as the placeholder
- ask = newAllocationAskTG(allocID, appID1, taskGroup, phRes, false)
+ ask = newAllocationAskTG(allocKey, appID1, taskGroup, phRes, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app")
alloc := partition.tryAllocate()
@@ -3272,7 +3257,7 @@ func TestPreemptedPlaceholderSkip(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: "test",
ApplicationID: appID1,
- AllocationID: phAllocationID,
+ AllocationKey: phAllocationKey,
TerminationType: si.TerminationType_PREEMPTED_BY_SCHEDULER,
}
released, confirmed := partition.removeAllocation(release)
@@ -3289,7 +3274,7 @@ func TestPreemptedPlaceholderSkip(t *testing.T) {
if alloc == nil {
t.Fatal("expected ask to be allocated (no placeholder left)")
}
- assert.Equal(t, allocID, alloc.GetAllocationKey(), "expected allocation
of alloc-1 to be returned")
+ assert.Equal(t, allocKey, alloc.GetAllocationKey(), "expected
allocation of alloc-1 to be returned")
assert.Equal(t, 1, len(app.GetAllPlaceholderData()), "placeholder data
should not be updated")
assert.Equal(t, int64(1), app.GetAllPlaceholderData()[0].Count,
"placeholder data should show 1 available placeholder")
assert.Equal(t, int64(0), app.GetAllPlaceholderData()[0].Replaced,
"placeholder data should show no replacements")
@@ -3335,7 +3320,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
if alloc == nil {
t.Fatal("expected first placeholder to be allocated")
}
- assert.Equal(t, node.GetAllocation(alloc.GetAllocationID()), alloc,
"placeholder allocation not found on node")
+ assert.Equal(t, node.GetAllocation(alloc.GetAllocationKey()), alloc,
"placeholder allocation not found on node")
assert.Assert(t, alloc.IsPlaceholder(), "placeholder alloc should
return a placeholder allocation")
assert.Equal(t, alloc.GetResult(), objects.Allocated, "placeholder
alloc should return an allocated result")
if !resources.Equals(app.GetPlaceholderResource(), res) {
@@ -3358,7 +3343,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
if alloc == nil {
t.Fatal("expected 2nd placeholder to be allocated")
}
- assert.Equal(t, node.GetAllocation(alloc.GetAllocationID()), alloc,
"placeholder allocation 2 not found on node")
+ assert.Equal(t, node.GetAllocation(alloc.GetAllocationKey()), alloc,
"placeholder allocation 2 not found on node")
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))
}
@@ -3367,7 +3352,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
assertLimits(t, getTestUserGroup(), resources.Multiply(res, 2))
// not mapping to the same taskgroup should not do anything
- ask = newAllocationAskTG(allocID, appID1, "tg-unk", res, false)
+ ask = newAllocationAskTG(allocKey, appID1, "tg-unk", res, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app")
alloc = partition.tryPlaceholderAllocate()
@@ -3377,7 +3362,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
assertLimits(t, getTestUserGroup(), resources.Multiply(res, 2))
// add an ask with the TG
- ask = newAllocationAskTG(allocID2, appID1, taskGroup, res, false)
+ ask = newAllocationAskTG(allocKey2, appID1, taskGroup, res, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-2 to app with correct
TG")
alloc = partition.tryPlaceholderAllocate()
@@ -3389,7 +3374,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
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")
assertLimits(t, getTestUserGroup(), resources.Multiply(res, 2))
- phAllocationID := alloc.GetFirstRelease().GetAllocationID()
+ phAllocationKey := alloc.GetFirstRelease().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))
@@ -3399,7 +3384,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: "test",
ApplicationID: appID1,
- AllocationID: phAllocationID,
+ AllocationKey: phAllocationKey,
TerminationType: si.TerminationType_PLACEHOLDER_REPLACED,
}
released, confirmed := partition.removeAllocation(release)
@@ -3409,7 +3394,7 @@ func TestTryPlaceholderAllocate(t *testing.T) {
if confirmed == nil {
t.Fatal("confirmed allocation should not be nil")
}
- assert.Equal(t, confirmed.GetAllocationID(), alloc.GetAllocationID(),
"confirmed allocation has unexpected AllocationID")
+ assert.Equal(t, confirmed.GetAllocationKey(), alloc.GetAllocationKey(),
"confirmed allocation has unexpected AllocationKey")
if !resources.Equals(app.GetPlaceholderResource(), res) {
t.Fatalf("placeholder allocations not updated as expected: got
%s, expected %s", app.GetPlaceholderResource(), res)
}
@@ -3459,7 +3444,7 @@ func TestFailReplacePlaceholder(t *testing.T) {
}
assert.Equal(t, partition.GetTotalAllocationCount(), 1, "placeholder
allocation should be counted as alloc")
assert.Equal(t, partition.getPhAllocationCount(), 1, "placeholder
allocation should be counted as placeholder")
- assert.Equal(t, node.GetAllocation(alloc.GetAllocationID()), alloc,
"placeholder allocation not found on node")
+ assert.Equal(t, node.GetAllocation(alloc.GetAllocationKey()), alloc,
"placeholder allocation not found on node")
assert.Assert(t, alloc.IsPlaceholder(), "placeholder alloc should
return a placeholder allocation")
assert.Equal(t, alloc.GetResult(), objects.Allocated, "placeholder
alloc should return an allocated result")
assert.Equal(t, alloc.GetNodeID(), nodeID1, "should be allocated on
node-1")
@@ -3470,7 +3455,7 @@ func TestFailReplacePlaceholder(t *testing.T) {
node2 := setupNode(t, nodeID2, partition, tgRes)
assertLimits(t, getTestUserGroup(), res)
// add an ask with the TG
- ask = newAllocationAskTG(allocID, appID1, taskGroup, res, false)
+ ask = newAllocationAskTG(allocKey, appID1, taskGroup, res, false)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "failed to add ask alloc-1 to app with correct
TG")
alloc = partition.tryPlaceholderAllocate()
@@ -3487,7 +3472,7 @@ func TestFailReplacePlaceholder(t *testing.T) {
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)
- phAllocationID := alloc.GetFirstRelease().GetAllocationID()
+ phAllocationKey := alloc.GetFirstRelease().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)
@@ -3496,7 +3481,7 @@ func TestFailReplacePlaceholder(t *testing.T) {
release := &si.AllocationRelease{
PartitionName: "test",
ApplicationID: appID1,
- AllocationID: phAllocationID,
+ AllocationKey: phAllocationKey,
TerminationType: si.TerminationType_PLACEHOLDER_REPLACED,
}
released, confirmed := partition.removeAllocation(release)
@@ -3506,7 +3491,7 @@ func TestFailReplacePlaceholder(t *testing.T) {
if confirmed == nil {
t.Fatal("confirmed allocation should not be nil")
}
- assert.Equal(t, confirmed.GetAllocationID(), alloc.GetAllocationID(),
"confirmed allocation has unexpected AllocationID")
+ assert.Equal(t, confirmed.GetAllocationKey(), alloc.GetAllocationKey(),
"confirmed allocation has unexpected AllocationKey")
assert.Assert(t, resources.IsZero(app.GetPlaceholderResource()),
"placeholder resources should be zero")
assert.Assert(t, resources.Equals(app.GetAllocatedResource(), res),
"allocations not updated as expected: got %s, expected %s",
app.GetAllocatedResource(), res)
assert.Assert(t, resources.IsZero(node.GetAllocatedResource()), "node-1
allocated resources should be zero")
@@ -3750,7 +3735,7 @@ func TestTryAllocateMaxRunning(t *testing.T) {
var res *resources.Resource
res, err = resources.NewResourceFromConf(map[string]string{resType:
"1"})
assert.NilError(t, err, "failed to create resource")
- err = app.AddAllocationAsk(newAllocationAskTG(allocID, appID1, "ph1",
res, true))
+ err = app.AddAllocationAsk(newAllocationAskTG(allocKey, appID1, "ph1",
res, true))
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
// first allocation should move the app to accepted
assert.Equal(t, app.CurrentState(), objects.Accepted.String(),
"application should have moved to accepted state")
@@ -3763,14 +3748,14 @@ func TestTryAllocateMaxRunning(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID1, "expected application
app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask alloc
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")
// add second app to the partition
app2 := newApplication(appID2, "default", "root.parent.sub-leaf")
err = partition.AddApplication(app2)
assert.NilError(t, err, "failed to add app-2 to partition")
- err = app2.AddAllocationAsk(newAllocationAsk(allocID, appID2, res))
+ err = app2.AddAllocationAsk(newAllocationAsk(allocKey, appID2, res))
assert.NilError(t, err, "failed to add ask alloc-1 to app-2")
// allocation should fail max running app is reached on parent via
accepted allocating
@@ -3808,7 +3793,7 @@ func TestTryAllocateMaxRunning(t *testing.T) {
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.Equal(t, alloc.GetApplicationID(), appID2, "expected application
app-2 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID, "expected ask
alloc-1 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey, "expected ask
alloc-1 to be allocated")
}
func TestNewQueueEvents(t *testing.T) {
@@ -3861,13 +3846,13 @@ func TestUserHeadroom(t *testing.T) {
err = partition.AddApplication(app1)
assert.NilError(t, err, "failed to add app-1 to partition")
- err = app1.AddAllocationAsk(newAllocationAsk(allocID, appID1, res))
+ err = app1.AddAllocationAsk(newAllocationAsk(allocKey, appID1, res))
assert.NilError(t, err, "failed to add ask alloc-1 to app-1")
app2 := newApplication(appID2, "default", "root.parent.sub-leaf")
err = partition.AddApplication(app2)
assert.NilError(t, err, "failed to add app-2 to partition")
- err = app2.AddAllocationAsk(newAllocationAsk(allocID, appID2, res))
+ err = app2.AddAllocationAsk(newAllocationAsk(allocKey, appID2, res))
assert.NilError(t, err, "failed to add ask alloc-1 to app-2")
// app 1 would be allocated as there is headroom available for the user
@@ -3889,7 +3874,7 @@ func TestUserHeadroom(t *testing.T) {
app3 := newApplication(appID3, "default", "root.leaf")
err = partition.AddApplication(app3)
assert.NilError(t, err, "failed to add app-3 to partition")
- err = app3.AddAllocationAsk(newAllocationAsk(allocID, appID3, res1))
+ err = app3.AddAllocationAsk(newAllocationAsk(allocKey, appID3, res1))
assert.NilError(t, err, "failed to add ask alloc-1 to app-3")
// app 3 would be allocated as there is headroom available for the user
@@ -3902,7 +3887,7 @@ func TestUserHeadroom(t *testing.T) {
app4 := newApplication("app-4", "default", "root.leaf")
err = partition.AddApplication(app4)
assert.NilError(t, err, "failed to add app-4 to partition")
- err = app4.AddAllocationAsk(newAllocationAsk(allocID, "app-4", res1))
+ err = app4.AddAllocationAsk(newAllocationAsk(allocKey, "app-4", res1))
assert.NilError(t, err, "failed to add ask alloc-1 to app-4")
// app 4 allocation won't happen as there is no headroom for the user
@@ -3962,7 +3947,7 @@ func TestUserHeadroom(t *testing.T) {
err = partition.AddApplication(app6)
assert.NilError(t, err, "failed to add app-6 to partition")
- err = app6.AddAllocationAsk(newAllocationAsk(allocID, "app-6", res))
+ err = app6.AddAllocationAsk(newAllocationAsk(allocKey, "app-6", res))
assert.NilError(t, err, "failed to add ask alloc-1 to app-6")
// app 6 would be allocated as headroom is nil because no limits
configured for 'testuser1' user an
@@ -3996,13 +3981,13 @@ func TestPlaceholderAllocationTracking(t *testing.T) {
assert.NilError(t, err, "could not add ask")
assert.Equal(t, 0, partition.getPhAllocationCount())
// add & allocate real asks
- ask4 := newAllocationAskTG(allocID, appID1, taskGroup, res, false)
+ ask4 := newAllocationAskTG(allocKey, appID1, taskGroup, res, false)
err = app.AddAllocationAsk(ask4)
assert.NilError(t, err, "failed to add ask to app")
// allocate first placeholder
alloc := partition.tryAllocate()
- ph1AllocationID := alloc.GetAllocationID()
+ ph1AllocationKey := alloc.GetAllocationKey()
assert.Assert(t, alloc != nil, "placeholder ask should have been
allocated")
assert.Equal(t, 1, partition.GetTotalAllocationCount(), "placeholder
not counted as alloc")
assert.Equal(t, 1, partition.getPhAllocationCount(), "placeholder not
counted as placeholder")
@@ -4013,33 +3998,33 @@ func TestPlaceholderAllocationTracking(t *testing.T) {
// allocate second placeholder
alloc = partition.tryAllocate()
- ph2AllocationID := alloc.GetAllocationID()
+ ph2AllocationKey := alloc.GetAllocationKey()
assert.Assert(t, alloc != nil, "placeholder ask should have been
allocated")
assert.Equal(t, 2, partition.GetTotalAllocationCount(), "placeholder
not counted as alloc")
assert.Equal(t, 2, partition.getPhAllocationCount(), "placeholder not
counted as placeholder")
// allocate third placeholder
alloc = partition.tryAllocate()
- ph3AllocationID := alloc.GetAllocationID()
+ ph3AllocationKey := alloc.GetAllocationKey()
assert.Assert(t, alloc != nil, "placeholder ask should have been
allocated")
assert.Equal(t, 3, partition.GetTotalAllocationCount(), "placeholder
not counted as alloc")
assert.Equal(t, 3, partition.getPhAllocationCount(), "placeholder not
counted as placeholder")
partition.removeAllocation(&si.AllocationRelease{
- AllocationID: ph1AllocationID,
+ AllocationKey: ph1AllocationKey,
ApplicationID: appID1,
TerminationType: si.TerminationType_PLACEHOLDER_REPLACED,
})
assert.Equal(t, 3, partition.GetTotalAllocationCount(), "placeholder
not counted as alloc")
assert.Equal(t, 2, partition.getPhAllocationCount(), "placeholder
should be removed from count")
partition.removeAllocation(&si.AllocationRelease{
- AllocationID: ph2AllocationID,
+ AllocationKey: ph2AllocationKey,
ApplicationID: appID1,
TerminationType: si.TerminationType_STOPPED_BY_RM,
})
assert.Equal(t, 2, partition.GetTotalAllocationCount(), "placeholder
should be removed from alloc count")
assert.Equal(t, 1, partition.getPhAllocationCount(), "placeholder
should be removed from count")
partition.removeAllocation(&si.AllocationRelease{
- AllocationID: ph3AllocationID,
+ AllocationKey: ph3AllocationKey,
ApplicationID: appID1,
TerminationType: si.TerminationType_TIMEOUT,
})
@@ -4058,17 +4043,17 @@ func TestReservationTracking(t *testing.T) {
// add to the partition
err = partition.AddApplication(app)
assert.NilError(t, err, "failed to add app to partition")
- ask1 := newAllocationAsk(allocID, appID1, res)
+ ask1 := newAllocationAsk(allocKey, appID1, res)
ask1.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask1)
assert.NilError(t, err, "failed to add ask")
- ask2 := newAllocationAsk(allocID2, appID1, res)
+ ask2 := newAllocationAsk(allocKey2, appID1, res)
ask2.SetRequiredNode(nodeID1)
err = app.AddAllocationAsk(ask2)
assert.NilError(t, err, "failed to add ask")
alloc := partition.tryAllocate() // ask1 occupies node1
- allocationID := alloc.GetAllocationID()
+ allocationKey := alloc.GetAllocationKey()
assert.Equal(t, objects.Allocated, alloc.GetResult())
assert.Equal(t, "alloc-1", alloc.GetAllocationKey())
assert.Equal(t, 0, partition.getReservationCount())
@@ -4077,7 +4062,7 @@ func TestReservationTracking(t *testing.T) {
assert.Equal(t, 1, partition.getReservationCount())
partition.removeAllocation(&si.AllocationRelease{
- AllocationID: allocationID,
+ AllocationKey: allocationKey,
ApplicationID: appID1,
TerminationType: si.TerminationType_STOPPED_BY_RM,
}) // terminate ask1
@@ -4216,7 +4201,7 @@ func TestLimitMaxApplications(t *testing.T) {
app1 := newApplication(appID1, "default", defQueue)
err = partition.AddApplication(app1)
assert.NilError(t, err, "add application to partition
should not have failed")
- err = app1.AddAllocationAsk(newAllocationAsk(allocID,
appID1, res))
+ err = app1.AddAllocationAsk(newAllocationAsk(allocKey,
appID1, res))
assert.NilError(t, err, "failed to add ask alloc-1 to
app-1")
alloc := partition.tryAllocate()
@@ -4225,13 +4210,13 @@ func TestLimitMaxApplications(t *testing.T) {
}
assert.Equal(t, alloc.GetResult(), objects.Allocated,
"result is not the expected allocated")
assert.Equal(t, alloc.GetApplicationID(), appID1,
"expected application app-1 to be allocated")
- assert.Equal(t, alloc.GetAllocationKey(), allocID,
"expected ask alloc-1 to be allocated")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey,
"expected ask alloc-1 to be allocated")
// add app2
app2 := newApplication(appID2, "default", defQueue)
err = partition.AddApplication(app2)
assert.NilError(t, err, "add application to partition
should not have failed")
- err = app2.AddAllocationAsk(newAllocationAsk(allocID2,
appID2, res))
+ err = app2.AddAllocationAsk(newAllocationAsk(allocKey2,
appID2, res))
assert.NilError(t, err, "failed to add ask alloc-2 to
app-1")
assert.Equal(t, app2.CurrentState(),
objects.Accepted.String(), "application should have moved to accepted state")
@@ -4372,7 +4357,7 @@ func TestLimitMaxApplicationsForReservedAllocation(t
*testing.T) {
app1 := newApplication(appID1, "default", defQueue)
err = partition.AddApplication(app1)
assert.NilError(t, err, "add application to partition
should not have failed")
- app1AllocAsk := newAllocationAsk(allocID, appID1, res)
+ app1AllocAsk := newAllocationAsk(allocKey, appID1, res)
err = app1.AddAllocationAsk(app1AllocAsk)
assert.NilError(t, err, "failed to add ask alloc-1 to
app-1")
@@ -4383,13 +4368,13 @@ func TestLimitMaxApplicationsForReservedAllocation(t
*testing.T) {
}
assert.Equal(t, alloc.GetResult(),
objects.AllocatedReserved, "result is not the expected allocated reserved")
assert.Equal(t, alloc.GetApplicationID(), appID1,
"expected application app-1 to be allocated reserved")
- assert.Equal(t, alloc.GetAllocationKey(), allocID,
"expected ask alloc-1 to be allocated reserved")
+ assert.Equal(t, alloc.GetAllocationKey(), allocKey,
"expected ask alloc-1 to be allocated reserved")
// add app2
app2 := newApplication(appID2, "default", defQueue)
err = partition.AddApplication(app2)
assert.NilError(t, err, "add application to partition
should not have failed")
- app2AllocAsk := newAllocationAsk(allocID2, appID2, res)
+ app2AllocAsk := newAllocationAsk(allocKey2, appID2, res)
err = app2.AddAllocationAsk(app2AllocAsk)
assert.NilError(t, err, "failed to add ask alloc-2 to
app-1")
assert.Equal(t, app2.CurrentState(),
objects.Accepted.String(), "application should have moved to accepted state")
@@ -4515,18 +4500,15 @@ func
TestPlaceholderAllocationAndReplacementAfterRecovery(t *testing.T) {
assert.Equal(t, objects.Replaced, alloc.GetResult())
assert.Equal(t, "real-alloc", alloc.GetAllocationKey())
assert.Equal(t, "tg-1", alloc.GetTaskGroup())
- assert.Equal(t, "real-alloc", alloc.GetAllocationID())
// remove the terminated placeholder allocation
released, confirmed := partition.removeAllocation(&si.AllocationRelease{
ApplicationID: appID1,
TerminationType: si.TerminationType_PLACEHOLDER_REPLACED,
- AllocationKey: "real-alloc",
- AllocationID: "placeholder",
+ AllocationKey: "placeholder",
})
assert.Assert(t, released == nil, "unexpected released allocation")
assert.Assert(t, confirmed != nil, "expected to have a confirmed
allocation")
assert.Equal(t, "real-alloc", confirmed.GetAllocationKey())
assert.Equal(t, "tg-1", confirmed.GetTaskGroup())
- assert.Equal(t, "real-alloc", confirmed.GetAllocationID())
}
diff --git a/pkg/scheduler/tests/application_tracking_test.go
b/pkg/scheduler/tests/application_tracking_test.go
index 9243b3dc..0d50497d 100644
--- a/pkg/scheduler/tests/application_tracking_test.go
+++ b/pkg/scheduler/tests/application_tracking_test.go
@@ -135,9 +135,9 @@ func TestApplicationHistoryTracking(t *testing.T) {
allocations := ms.mockRM.getAllocations()
assert.Equal(t, 1, len(allocations), "number of allocations")
- var allocationID string
+ var allocationKey string
for key := range allocations {
- allocationID = key
+ allocationKey = key
}
// terminate allocation & check events
@@ -147,7 +147,7 @@ func TestApplicationHistoryTracking(t *testing.T) {
{
ApplicationID: appID1,
PartitionName: "default",
- AllocationID: allocationID,
+ AllocationKey: allocationKey,
TerminationType:
si.TerminationType_STOPPED_BY_RM,
},
},
diff --git a/pkg/scheduler/tests/mock_rm_callback_test.go
b/pkg/scheduler/tests/mock_rm_callback_test.go
index a908683d..b3f5419a 100644
--- a/pkg/scheduler/tests/mock_rm_callback_test.go
+++ b/pkg/scheduler/tests/mock_rm_callback_test.go
@@ -79,7 +79,7 @@ func (m *mockRMCallback) UpdateAllocation(response
*si.AllocationResponse) error
m.Lock()
defer m.Unlock()
for _, alloc := range response.New {
- m.Allocations[alloc.AllocationID] = alloc
+ m.Allocations[alloc.AllocationKey] = alloc
if val, ok := m.nodeAllocations[alloc.NodeID]; ok {
val = append(val, alloc)
m.nodeAllocations[alloc.NodeID] = val
@@ -90,9 +90,9 @@ func (m *mockRMCallback) UpdateAllocation(response
*si.AllocationResponse) error
}
}
for _, alloc := range response.Released {
- delete(m.Allocations, alloc.AllocationID)
+ delete(m.Allocations, alloc.AllocationKey)
if alloc.TerminationType ==
si.TerminationType_PLACEHOLDER_REPLACED {
- m.releasedPhs[alloc.AllocationID] = alloc
+ m.releasedPhs[alloc.AllocationKey] = alloc
}
}
return nil
diff --git a/pkg/scheduler/tests/mockscheduler_test.go
b/pkg/scheduler/tests/mockscheduler_test.go
index 222aa390..9031ff2d 100644
--- a/pkg/scheduler/tests/mockscheduler_test.go
+++ b/pkg/scheduler/tests/mockscheduler_test.go
@@ -146,11 +146,11 @@ func (m *mockScheduler) removeApp(appID, partition
string) error {
})
}
-func (m *mockScheduler) addAppRequest(appID, allocID string, resource
*si.Resource, repeat int) error {
+func (m *mockScheduler) addAppRequest(appID, allocKeyPrefix string, resource
*si.Resource, repeat int) error {
asks := make([]*si.AllocationAsk, repeat)
for i := 0; i < repeat; i++ {
asks[i] = &si.AllocationAsk{
- AllocationKey: fmt.Sprintf("%s-%d", allocID, i),
+ AllocationKey: fmt.Sprintf("%s-%d", allocKeyPrefix, i),
ApplicationID: appID,
ResourceAsk: resource,
}
@@ -161,13 +161,13 @@ func (m *mockScheduler) addAppRequest(appID, allocID
string, resource *si.Resour
})
}
-func (m *mockScheduler) releaseAllocRequest(appID, allocationID string) error {
+func (m *mockScheduler) releaseAllocRequest(appID, allocationKey string) error
{
return m.proxy.UpdateAllocation(&si.AllocationRequest{
Releases: &si.AllocationReleasesRequest{
AllocationsToRelease: []*si.AllocationRelease{
{
ApplicationID: appID,
- AllocationID: allocationID,
+ AllocationKey: allocationKey,
PartitionName: m.partitionName,
},
},
diff --git a/pkg/scheduler/tests/recovery_test.go
b/pkg/scheduler/tests/recovery_test.go
index 75c1f470..8b657155 100644
--- a/pkg/scheduler/tests/recovery_test.go
+++ b/pkg/scheduler/tests/recovery_test.go
@@ -483,7 +483,6 @@ func TestSchedulerRecoveryWithoutAppInfo(t *testing.T) {
ExistingAllocations: []*si.Allocation{
{
AllocationKey:
"allocation-key-01",
- AllocationID: "ALLOCATIONID01",
ApplicationID: "app-01",
PartitionName: "default",
NodeID: "node-1:1234",
@@ -551,7 +550,6 @@ func TestSchedulerRecoveryWithoutAppInfo(t *testing.T) {
ExistingAllocations: []*si.Allocation{
{
AllocationKey:
"allocation-key-01",
- AllocationID: "ALLOCATIONID01",
ApplicationID: "app-01",
PartitionName: "default",
NodeID: "node-1:1234",
@@ -864,7 +862,6 @@ partitions:
existingAllocations = append(existingAllocations,
&si.Allocation{
AllocationKey: alloc.AllocationKey,
AllocationTags: alloc.AllocationTags,
- AllocationID: alloc.AllocationID,
ResourcePerAlloc: alloc.ResourcePerAlloc,
Priority: alloc.Priority,
NodeID: alloc.NodeID,
@@ -959,7 +956,6 @@ func TestPlaceholderRecovery(t *testing.T) { //nolint:funlen
NodeID: "node-1:1234",
ApplicationID: appID1,
TaskGroupName: "tg-1",
- AllocationID: "ph-alloc-1-0",
ResourcePerAlloc: &si.Resource{
Resources: map[string]*si.Quantity{
"memory": {
@@ -1025,9 +1021,9 @@ func TestPlaceholderRecovery(t *testing.T) {
//nolint:funlen
"vcore": {Value: 1},
},
},
- ApplicationID: appID1,
- TaskGroupName: "tg-2",
- Placeholder: true,
+ ApplicationID: appID1,
+ TaskGroupName: "tg-2",
+ Placeholder: true,
},
},
RmID: "rm:123",
@@ -1046,8 +1042,8 @@ func TestPlaceholderRecovery(t *testing.T) {
//nolint:funlen
"vcore": {Value: 1},
},
},
- ApplicationID: appID1,
- TaskGroupName: "tg-1",
+ ApplicationID: appID1,
+ TaskGroupName: "tg-1",
},
{
AllocationKey: "real-alloc-2",
@@ -1057,8 +1053,8 @@ func TestPlaceholderRecovery(t *testing.T) {
//nolint:funlen
"vcore": {Value: 1},
},
},
- ApplicationID: appID1,
- TaskGroupName: "tg-2",
+ ApplicationID: appID1,
+ TaskGroupName: "tg-2",
},
},
RmID: "rm:123",
@@ -1073,13 +1069,13 @@ func TestPlaceholderRecovery(t *testing.T) {
//nolint:funlen
{
ApplicationID: appID1,
PartitionName: "default",
- AllocationID: "ph-alloc-1",
+ AllocationKey: "ph-alloc-1",
TerminationType:
si.TerminationType_PLACEHOLDER_REPLACED,
},
{
ApplicationID: appID1,
PartitionName: "default",
- AllocationID: "ph-alloc-2",
+ AllocationKey: "ph-alloc-2",
TerminationType:
si.TerminationType_PLACEHOLDER_REPLACED,
},
},
@@ -1095,13 +1091,13 @@ func TestPlaceholderRecovery(t *testing.T) {
//nolint:funlen
{
ApplicationID: appID1,
PartitionName: "default",
- AllocationID: "real-alloc-1",
+ AllocationKey: "real-alloc-1",
TerminationType:
si.TerminationType_STOPPED_BY_RM,
},
{
ApplicationID: appID1,
PartitionName: "default",
- AllocationID: "real-alloc-2",
+ AllocationKey: "real-alloc-2",
TerminationType:
si.TerminationType_STOPPED_BY_RM,
},
},
diff --git a/pkg/scheduler/tests/reservation_test.go
b/pkg/scheduler/tests/reservation_test.go
index 426093e3..3cd59c20 100644
--- a/pkg/scheduler/tests/reservation_test.go
+++ b/pkg/scheduler/tests/reservation_test.go
@@ -422,7 +422,7 @@ func TestUnReservationAndDeletion(t *testing.T) {
}
// delete existing allocations
for _, alloc := range ms.mockRM.getAllocations() {
- err = ms.releaseAllocRequest(appID1, alloc.AllocationID)
+ err = ms.releaseAllocRequest(appID1, alloc.AllocationKey)
assert.NilError(t, err, "allocation release update failed")
}
ms.scheduler.MultiStepSchedule(5)
diff --git a/pkg/scheduler/tests/smoke_test.go
b/pkg/scheduler/tests/smoke_test.go
index e25269dd..dcf6d8c1 100644
--- a/pkg/scheduler/tests/smoke_test.go
+++ b/pkg/scheduler/tests/smoke_test.go
@@ -366,7 +366,7 @@ func TestBasicScheduler(t *testing.T) {
// Release all allocations
for _, v := range ms.mockRM.getAllocations() {
updateRequest.Releases.AllocationsToRelease =
append(updateRequest.Releases.AllocationsToRelease, &si.AllocationRelease{
- AllocationID: v.AllocationID,
+ AllocationKey: v.AllocationKey,
ApplicationID: v.ApplicationID,
PartitionName: v.PartitionName,
})
@@ -917,7 +917,7 @@ partitions:
allocReleases = append(allocReleases,
&si.AllocationRelease{
PartitionName: "default",
ApplicationID: appID1,
- AllocationID: alloc.AllocationID,
+ AllocationKey: alloc.AllocationKey,
Message: "",
})
}
@@ -1411,7 +1411,7 @@ func TestDupReleasesInGangScheduling(t *testing.T) {
{
PartitionName: "default",
ApplicationID: appID1,
- AllocationID:
placeholderAlloc.GetAllocationID(),
+ AllocationKey:
placeholderAlloc.GetAllocationKey(),
TerminationType:
si.TerminationType_PLACEHOLDER_REPLACED,
},
},
@@ -1440,7 +1440,7 @@ func TestDupReleasesInGangScheduling(t *testing.T) {
{
PartitionName: "default",
ApplicationID: appID1,
- AllocationID:
placeholderAlloc.GetAllocationID(),
+ AllocationKey:
placeholderAlloc.GetAllocationKey(),
TerminationType:
si.TerminationType_PLACEHOLDER_REPLACED,
},
},
@@ -1605,7 +1605,7 @@ partitions:
// Release all allocations
for _, v := range ms.mockRM.getAllocations() {
updateRequest.Releases.AllocationsToRelease =
append(updateRequest.Releases.AllocationsToRelease, &si.AllocationRelease{
- AllocationID: v.AllocationID,
+ AllocationKey: v.AllocationKey,
ApplicationID: v.ApplicationID,
PartitionName: v.PartitionName,
})
diff --git a/pkg/scheduler/utilities_test.go b/pkg/scheduler/utilities_test.go
index 5736c524..c9fade0a 100644
--- a/pkg/scheduler/utilities_test.go
+++ b/pkg/scheduler/utilities_test.go
@@ -47,9 +47,9 @@ const (
taskGroup = "tg-1"
phID = "ph-1"
phID2 = "ph-2"
- allocID = "alloc-1"
- allocID2 = "alloc-2"
- allocID3 = "alloc-3"
+ allocKey = "alloc-1"
+ allocKey2 = "alloc-2"
+ allocKey3 = "alloc-3"
maxresources = "maxresources"
maxapplications = "maxapplications"
)
diff --git a/pkg/webservice/dao/allocation_info.go
b/pkg/webservice/dao/allocation_info.go
index 90925bd1..8c9ea2ff 100644
--- a/pkg/webservice/dao/allocation_info.go
+++ b/pkg/webservice/dao/allocation_info.go
@@ -24,8 +24,6 @@ type AllocationDAOInfo struct {
RequestTime int64 `json:"requestTime,omitempty"`
// Allocation ask's createTime if PlaceholderUsed is false, otherwise
equivalent to placeholder allocation's createTime
AllocationTime int64 `json:"allocationTime,omitempty"`
// Allocation's createTime
AllocationDelay int64 `json:"allocationDelay,omitempty"`
// Difference between AllocationTime and RequestTime
- UUID string `json:"uuid,omitempty"`
// Deprecated. Need to remove this in next major release
- AllocationID string `json:"allocationID,omitempty"`
// Added to replace UUID.
ResourcePerAlloc map[string]int64 `json:"resource,omitempty"`
Priority string `json:"priority,omitempty"`
NodeID string `json:"nodeId,omitempty"`
diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index cab7fb77..73c76019 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -219,8 +219,6 @@ func getAllocationDAO(alloc *objects.Allocation)
*dao.AllocationDAOInfo {
RequestTime: requestTime,
AllocationTime: allocTime,
AllocationDelay: allocTime - requestTime,
- UUID: alloc.GetAllocationID(),
- AllocationID: alloc.GetAllocationID(),
ResourcePerAlloc: alloc.GetAllocatedResource().DAOMap(),
PlaceholderUsed: alloc.IsPlaceholderUsed(),
Placeholder: alloc.IsPlaceholder(),
diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index 6c908e85..bb6e38df 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -1302,15 +1302,11 @@ func TestGetPartitionNodes(t *testing.T) {
if node.NodeID == node1ID {
assert.Equal(t, node.NodeID, node1ID)
assert.Equal(t, "alloc-1",
node.Allocations[0].AllocationKey)
- assert.Equal(t, "alloc-1", node.Allocations[0].UUID)
- assert.Equal(t, "alloc-1",
node.Allocations[0].AllocationID)
assert.DeepEqual(t, attributesOfnode1, node.Attributes)
assert.DeepEqual(t, map[string]int64{"memory": 50,
"vcore": 30}, node.Utilized)
} else {
assert.Equal(t, node.NodeID, node2ID)
assert.Equal(t, "alloc-2",
node.Allocations[0].AllocationKey)
- assert.Equal(t, "alloc-2", node.Allocations[0].UUID)
- assert.Equal(t, "alloc-2",
node.Allocations[0].AllocationID)
assert.DeepEqual(t, attributesOfnode2, node.Attributes)
assert.DeepEqual(t, map[string]int64{"memory": 30,
"vcore": 50}, node.Utilized)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]