Skip to content

Commit

Permalink
[YUNIKORN-2942] Expose foreign allocations tags on the REST interface
Browse files Browse the repository at this point in the history
  • Loading branch information
pbacsko committed Oct 21, 2024
1 parent 079a02d commit a2c871d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/webservice/dao/allocation_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ type AllocationDAOInfo struct {
}

type ForeignAllocationDAOInfo struct {
AllocationKey string `json:"allocationKey"` // no omitempty, allocation key should not be empty
AllocationTime int64 `json:"allocationTime,omitempty"`
ResourcePerAlloc map[string]int64 `json:"resource,omitempty"`
Priority string `json:"priority,omitempty"`
NodeID string `json:"nodeId,omitempty"`
Preemptable bool `json:"preemptable,omitempty"`
AllocationKey string `json:"allocationKey"` // no omitempty, allocation key should not be empty
AllocationTags map[string]string `json:"allocationTags,omitempty"`
AllocationTime int64 `json:"allocationTime,omitempty"`
ResourcePerAlloc map[string]int64 `json:"resource,omitempty"`
Priority string `json:"priority,omitempty"`
NodeID string `json:"nodeId,omitempty"`
Preemptable bool `json:"preemptable,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/webservice/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func getForeignAllocationDAO(alloc *objects.Allocation) *dao.ForeignAllocationDA
allocTime := alloc.GetCreateTime().UnixNano()
allocDAO := &dao.ForeignAllocationDAOInfo{
AllocationKey: alloc.GetAllocationKey(),
AllocationTags: alloc.GetTagsClone(),
AllocationTime: allocTime,
ResourcePerAlloc: alloc.GetAllocatedResource().DAOMap(),
Priority: strconv.Itoa(int(alloc.GetPriority())),
Expand Down
6 changes: 6 additions & 0 deletions pkg/webservice/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,12 @@ func assertForeignAllocation(t *testing.T, key, priority, nodeID string, expecte
resFromInfo := resources.NewResourceFromMap(resMap)
assert.Assert(t, resources.Equals(resFromInfo, expectedRes))
assert.Equal(t, preemptable, info.Preemptable)
assert.Equal(t, 1, len(info.AllocationTags))
if info.AllocationKey == "foreign-1" {
assert.Equal(t, siCommon.AllocTypeDefault, info.AllocationTags[siCommon.Foreign])
} else {
assert.Equal(t, siCommon.AllocTypeStatic, info.AllocationTags[siCommon.Foreign])
}
}

// addApp Add app to the given partition and assert the app count, state etc
Expand Down

0 comments on commit a2c871d

Please sign in to comment.