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 11, 2022
1 parent 1dfaae7 commit e7b7a0b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type ClusterContext struct {
needPreemption bool
reservationDisabled bool

rmInfo map[string]*RMInformation
rmInfo map[string]*RMInformation
startTime time.Time

sync.RWMutex
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/objects/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type Application struct {
gangSchedulingStyle string // gang scheduling style can be hard (after timeout we fail the application), or soft (after timeeout we schedule it as a normal application)
finishedTime time.Time // the time of finishing this application. the default value is zero time
rejectedMessage string // If the application is rejected, save the rejected message
placeholderData map[string]*PlaceholderData // expose gang related info in application REST info
placeholderData map[string]*PlaceholderData // expose gang related info in application REST info

rmEventHandler handler.EventHandler
rmID string
Expand Down
17 changes: 9 additions & 8 deletions pkg/scheduler/objects/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,9 @@ func TestStateChangeOnPlaceholderAdd(t *testing.T) {
res := resources.NewResourceFromMap(map[string]resources.Quantity{"first": 1})
askID := "ask-1"
tgName := "TG1"
requiredNode := "node-1"
ask := newAllocationAskTG(askID, appID1, tgName, res, 1)
ask.requiredNode = "node-1"
ask.requiredNode = requiredNode
err = app.AddAllocationAsk(ask)
assert.NilError(t, err, "ask should have been added to app")
// app with ask, even for placeholder, should be accepted
Expand All @@ -672,25 +673,25 @@ func TestStateChangeOnPlaceholderAdd(t *testing.T) {
clonePlaceholderData := app.GetAllPlaceholderData()
assert.Assert(t, len(clonePlaceholderData) == 1)
assert.Assert(t, len(app.placeholderData) == 1)
assert.Equal(t,clonePlaceholderData[0],app.placeholderData[tgName])
assert.Equal(t, app.placeholderData[tgName].TaskGroupName, "TG1")
assert.Equal(t, clonePlaceholderData[0], app.placeholderData[tgName])
assert.Equal(t, app.placeholderData[tgName].TaskGroupName, tgName)
assert.Equal(t, app.placeholderData[tgName].Count, int64(1))
assert.Assert(t, resources.Equals(app.placeholderData[tgName].MinResource, res))
assert.Equal(t, app.placeholderData[tgName].RequiredNode, "node-1")
assert.Equal(t, app.placeholderData[tgName].RequiredNode, requiredNode)
assert.Equal(t, app.placeholderData[tgName].Replaced, int64(0))
// add second placeholder
ask2 := newAllocationAskTG(askID, appID1, tgName, res, 1)
ask2.requiredNode = "node-1"
ask2.requiredNode = requiredNode
err = app.AddAllocationAsk(ask2)
assert.NilError(t, err, "ask should have been added to app")
clonePlaceholderData = app.GetAllPlaceholderData()
assert.Assert(t, len(clonePlaceholderData) == 1)
assert.Assert(t, len(app.placeholderData) == 1)
assert.Equal(t,clonePlaceholderData[0],app.placeholderData[tgName])
assert.Equal(t, app.placeholderData[tgName].TaskGroupName, "TG1")
assert.Equal(t, clonePlaceholderData[0], app.placeholderData[tgName])
assert.Equal(t, app.placeholderData[tgName].TaskGroupName, tgName)
assert.Equal(t, app.placeholderData[tgName].Count, int64(2))
assert.Assert(t, resources.Equals(app.placeholderData[tgName].MinResource, res))
assert.Equal(t, app.placeholderData[tgName].RequiredNode, "node-1")
assert.Equal(t, app.placeholderData[tgName].RequiredNode, requiredNode)
assert.Equal(t, app.placeholderData[tgName].Replaced, int64(0))

// removing the ask should move it to waiting
Expand Down
22 changes: 11 additions & 11 deletions pkg/webservice/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,17 @@ func getApplicationJSON(app *objects.Application) *dao.ApplicationDAOInfo {
}

return &dao.ApplicationDAOInfo{
ApplicationID: app.ApplicationID,
UsedResource: app.GetAllocatedResource().DAOString(),
MaxUsedResource: app.GetMaxAllocatedResource().DAOString(),
Partition: common.GetPartitionNameWithoutClusterID(app.Partition),
QueueName: app.QueuePath,
SubmissionTime: app.SubmissionTime.UnixNano(),
FinishedTime: common.ZeroTimeInUnixNano(app.FinishedTime()),
Allocations: allocationInfo,
State: app.CurrentState(),
User: app.GetUser().User,
RejectedMessage: app.GetRejectedMessage(),
ApplicationID: app.ApplicationID,
UsedResource: app.GetAllocatedResource().DAOString(),
MaxUsedResource: app.GetMaxAllocatedResource().DAOString(),
Partition: common.GetPartitionNameWithoutClusterID(app.Partition),
QueueName: app.QueuePath,
SubmissionTime: app.SubmissionTime.UnixNano(),
FinishedTime: common.ZeroTimeInUnixNano(app.FinishedTime()),
Allocations: allocationInfo,
State: app.CurrentState(),
User: app.GetUser().User,
RejectedMessage: app.GetRejectedMessage(),
PlaceholderData: placeholderInfo,
}
}
Expand Down

0 comments on commit e7b7a0b

Please sign in to comment.