Skip to content

Commit

Permalink
[YUNIKORN-998] expose gang related info in application REST info
Browse files Browse the repository at this point in the history
  • Loading branch information
steinsgateted committed Mar 10, 2022
1 parent d58052f commit 00be2c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
10 changes: 6 additions & 4 deletions pkg/scheduler/objects/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,10 +1541,12 @@ func (sa *Application) SetPlaceholderData(taskGroupName string, allocatedResourc
if sa.PlaceholderDatas == nil {
sa.PlaceholderDatas = make(map[string]*PlaceholderData)
}
sa.PlaceholderDatas[taskGroupName] = &PlaceholderData{
TaskGroupName: taskGroupName,
RequiredNode: requiredNode,
AllocatedResource: allocatedResource,
if _, ok := sa.PlaceholderDatas[taskGroupName]; !ok {
sa.PlaceholderDatas[taskGroupName] = &PlaceholderData{
TaskGroupName: taskGroupName,
RequiredNode: requiredNode,
AllocatedResource: allocatedResource,
}
}
sa.PlaceholderDatas[taskGroupName].Count++
}
19 changes: 12 additions & 7 deletions pkg/webservice/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ func getApplicationJSON(app *objects.Application) *dao.ApplicationDAOInfo {
allocations := app.GetAllAllocations()
allocationInfos := make([]dao.AllocationDAOInfo, 0, len(allocations))
placeHolderInfos := make([]dao.PlaceholderDAOInfo, 0, len(app.PlaceholderDatas))
// Used to confirm whether the taskGroupName is duplicated
taskGroupNames := map[string]bool{}

for _, alloc := range allocations {
allocInfo := dao.AllocationDAOInfo{
Expand All @@ -295,14 +297,17 @@ func getApplicationJSON(app *objects.Application) *dao.ApplicationDAOInfo {

if alloc.IsPlaceholder() {
taskGroupName := alloc.GetTaskGroup()
placeHolderInfo := dao.PlaceholderDAOInfo{
TaskGroupName: taskGroupName,
RequiredNode: app.PlaceholderDatas[taskGroupName].RequiredNode,
AllocatedResource: app.PlaceholderDatas[taskGroupName].AllocatedResource,
Count: app.PlaceholderDatas[taskGroupName].Count,
Replaced: app.PlaceholderDatas[taskGroupName].Replaced,
if _, ok := taskGroupNames[taskGroupName]; !ok {
taskGroupNames[taskGroupName] = true
placeHolderInfo := dao.PlaceholderDAOInfo{
TaskGroupName: taskGroupName,
RequiredNode: app.PlaceholderDatas[taskGroupName].RequiredNode,
AllocatedResource: app.PlaceholderDatas[taskGroupName].AllocatedResource,
Count: app.PlaceholderDatas[taskGroupName].Count,
Replaced: app.PlaceholderDatas[taskGroupName].Replaced,
}
placeHolderInfos = append(placeHolderInfos, placeHolderInfo)
}
placeHolderInfos = append(placeHolderInfos, placeHolderInfo)
}
}

Expand Down

0 comments on commit 00be2c0

Please sign in to comment.