From 42c9d54f6a759c564118835150e6ae881aad0775 Mon Sep 17 00:00:00 2001 From: steinsgateted Date: Fri, 11 Mar 2022 01:50:44 +0800 Subject: [PATCH] [YUNIKORN-998] expose gang related info in application REST info --- pkg/scheduler/objects/application.go | 1 - pkg/scheduler/objects/application_test.go | 21 ++++++++++++++++++++- pkg/webservice/dao/application_info.go | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/objects/application.go b/pkg/scheduler/objects/application.go index 4b679b01e..b319fa645 100644 --- a/pkg/scheduler/objects/application.go +++ b/pkg/scheduler/objects/application.go @@ -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", diff --git a/pkg/scheduler/objects/application_test.go b/pkg/scheduler/objects/application_test.go index c9d6333ed..b87eed5af 100644 --- a/pkg/scheduler/objects/application_test.go +++ b/pkg/scheduler/objects/application_test.go @@ -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) diff --git a/pkg/webservice/dao/application_info.go b/pkg/webservice/dao/application_info.go index 6dc122304..8a798208d 100644 --- a/pkg/webservice/dao/application_info.go +++ b/pkg/webservice/dao/application_info.go @@ -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"` }