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 00be2c0 commit 3ac75e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
18 changes: 9 additions & 9 deletions pkg/scheduler/objects/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const (
)

type PlaceholderData struct {
TaskGroupName string
RequiredNode string
AllocatedResource *resources.Resource
Count int64
Replaced int64
TaskGroupName string
Count int64
MinResource *resources.Resource
RequiredNode string
Replaced int64
}

type Application struct {
Expand Down Expand Up @@ -1535,17 +1535,17 @@ func (sa *Application) GetRejectedMessage() string {
return sa.rejectedMessage
}

func (sa *Application) SetPlaceholderData(taskGroupName string, allocatedResource *resources.Resource, requiredNode string) {
func (sa *Application) SetPlaceholderData(taskGroupName string, minResource *resources.Resource, requiredNode string) {
sa.Lock()
defer sa.Unlock()
if sa.PlaceholderDatas == nil {
sa.PlaceholderDatas = make(map[string]*PlaceholderData)
}
if _, ok := sa.PlaceholderDatas[taskGroupName]; !ok {
sa.PlaceholderDatas[taskGroupName] = &PlaceholderData{
TaskGroupName: taskGroupName,
RequiredNode: requiredNode,
AllocatedResource: allocatedResource,
TaskGroupName: taskGroupName,
MinResource: minResource,
RequiredNode: requiredNode,
}
}
sa.PlaceholderDatas[taskGroupName].Count++
Expand Down
10 changes: 5 additions & 5 deletions pkg/webservice/dao/application_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ type AllocationDAOInfo struct {
}

type PlaceholderDAOInfo struct {
TaskGroupName string `json:"taskGroupName"`
RequiredNode string `json:"requiredNode"`
AllocatedResource *resources.Resource `json:"allocatedResource"`
Count int64 `json:"count"`
Replaced int64 `json:"replaced"`
TaskGroupName string `json:"taskGroupName"`
Count int64 `json:"count"`
MinResource *resources.Resource `json:"allocatedResource"`
RequiredNode string `json:"requiredNode"`
Replaced int64 `json:"replaced"`
}
12 changes: 5 additions & 7 deletions pkg/webservice/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ func getApplicationJSON(app *objects.Application) *dao.ApplicationDAOInfo {
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{
AllocationKey: alloc.AllocationKey,
Expand All @@ -294,17 +293,16 @@ func getApplicationJSON(app *objects.Application) *dao.ApplicationDAOInfo {
Partition: alloc.PartitionName,
}
allocationInfos = append(allocationInfos, allocInfo)

if alloc.IsPlaceholder() {
taskGroupName := alloc.GetTaskGroup()
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,
TaskGroupName: taskGroupName,
Count: app.PlaceholderDatas[taskGroupName].Count,
MinResource: app.PlaceholderDatas[taskGroupName].MinResource,
RequiredNode: app.PlaceholderDatas[taskGroupName].RequiredNode,
Replaced: app.PlaceholderDatas[taskGroupName].Replaced,
}
placeHolderInfos = append(placeHolderInfos, placeHolderInfo)
}
Expand Down

0 comments on commit 3ac75e6

Please sign in to comment.