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 3ac75e6 commit 42c9d54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 0 additions & 1 deletion pkg/scheduler/objects/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,6 @@ func (sa *Application) tryPlaceholderAllocate(nodeIterator func() NodeIterator,
if sa.PlaceholderDatas != nil {
sa.PlaceholderDatas[ph.taskGroupName].Replaced++
}
// The number of replaced placeHolder
_, err := sa.updateAskRepeatInternal(request, -1)
if err != nil {
log.Logger().Warn("ask repeat update failed unexpectedly",
Expand Down
21 changes: 20 additions & 1 deletion pkg/scheduler/objects/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,30 @@ func TestStateChangeOnPlaceholderAdd(t *testing.T) {
assert.Assert(t, app.IsNew(), "New application did not return new state: %s", app.CurrentState())
res := resources.NewResourceFromMap(map[string]resources.Quantity{"first": 1})
askID := "ask-1"
ask := newAllocationAskTG(askID, appID1, "TG1", res, 1)
tgName := "TG1"
ask := newAllocationAskTG(askID, appID1, tgName, res, 1)
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "ask should have been added to app")
// app with ask, even for placeholder, should be accepted
assert.Assert(t, app.IsAccepted(), "application did not change to accepted state: %s", app.CurrentState())
// save placeholder data
app.SetPlaceholderData(tgName, res, "node-1")
assert.Assert(t, len(app.PlaceholderDatas) == 1, "PlaceholderDatas should have 1 taskGroup information")
assert.Equal(t, app.PlaceholderDatas[tgName].TaskGroupName, "TG1")
assert.Equal(t, app.PlaceholderDatas[tgName].Count, int64(1))
assert.Equal(t, app.PlaceholderDatas[tgName].MinResource, res)
assert.Equal(t, app.PlaceholderDatas[tgName].RequiredNode, "node-1")
assert.Equal(t, app.PlaceholderDatas[tgName].Replaced, int64(0))
// add second placeholder
ask2 := newAllocationAskTG(askID, appID1, tgName, res, 1)
err = app.AddAllocationAsk(ask2)
app.SetPlaceholderData(tgName, res, "node-1")
assert.Assert(t, len(app.PlaceholderDatas) == 1, "PlaceholderDatas should have 1 taskGroup information")
assert.Equal(t, app.PlaceholderDatas[tgName].TaskGroupName, "TG1")
assert.Equal(t, app.PlaceholderDatas[tgName].Count, int64(2))
assert.Equal(t, app.PlaceholderDatas[tgName].MinResource, res)
assert.Equal(t, app.PlaceholderDatas[tgName].RequiredNode, "node-1")
assert.Equal(t, app.PlaceholderDatas[tgName].Replaced, int64(0))

// removing the ask should move it to waiting
released := app.RemoveAllocationAsk(askID)
Expand Down
2 changes: 1 addition & 1 deletion pkg/webservice/dao/application_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type AllocationDAOInfo struct {
type PlaceholderDAOInfo struct {
TaskGroupName string `json:"taskGroupName"`
Count int64 `json:"count"`
MinResource *resources.Resource `json:"allocatedResource"`
MinResource *resources.Resource `json:"minResource"`
RequiredNode string `json:"requiredNode"`
Replaced int64 `json:"replaced"`
}

0 comments on commit 42c9d54

Please sign in to comment.