Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-2044] remove GetQueueInfo function #676

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions pkg/scheduler/objects/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,33 +589,6 @@ func (sq *Queue) CheckAdminAccess(user security.UserGroup) bool {
return allow
}

// GetQueueInfo returns the queue hierarchy as an object for a REST call.
// This object is used by the deprecated REST API and is succeeded by the GetPartitionQueueDAOInfo call.
func (sq *Queue) GetQueueInfo() dao.QueueDAOInfo {
queueInfo := dao.QueueDAOInfo{}
for _, child := range sq.GetCopyOfChildren() {
queueInfo.ChildQueues = append(queueInfo.ChildQueues, child.GetQueueInfo())
}

// children are done we can now lock just this queue.
sq.RLock()
defer sq.RUnlock()
queueInfo.QueueName = sq.Name
queueInfo.Status = sq.stateMachine.Current()
queueInfo.Capacities = dao.QueueCapacity{
Capacity: sq.guaranteedResource.DAOMap(),
MaxCapacity: sq.maxResource.DAOMap(),
UsedCapacity: sq.allocatedResource.DAOMap(),
AbsUsedCapacity: resources.CalculateAbsUsedCapacity(
sq.maxResource, sq.allocatedResource).DAOMap(),
}
queueInfo.Properties = make(map[string]string)
for k, v := range sq.properties {
queueInfo.Properties[k] = v
}
return queueInfo
}

// GetPartitionQueueDAOInfo returns the queue hierarchy as an object for a REST call.
func (sq *Queue) GetPartitionQueueDAOInfo() dao.PartitionQueueDAOInfo {
queueInfo := dao.PartitionQueueDAOInfo{}
Expand Down
115 changes: 0 additions & 115 deletions pkg/scheduler/objects/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/apache/yunikorn-core/pkg/events"
"github.com/apache/yunikorn-core/pkg/scheduler/objects/template"
"github.com/apache/yunikorn-core/pkg/scheduler/policies"
"github.com/apache/yunikorn-core/pkg/webservice/dao"
siCommon "github.com/apache/yunikorn-scheduler-interface/lib/go/common"
"github.com/apache/yunikorn-scheduler-interface/lib/go/si"
)
Expand Down Expand Up @@ -1603,120 +1602,6 @@ func TestMaxResource(t *testing.T) {
}
}

func TestGetQueueInfo(t *testing.T) {
root, err := createRootQueue(nil)
assert.NilError(t, err, "failed to create basic root queue: %v", err)
var rootMax *resources.Resource
rootMax, err = resources.NewResourceFromConf(map[string]string{"memory": "2048", "vcores": "10"})
assert.NilError(t, err, "failed to create configuration: %v", err)
root.SetMaxResource(rootMax)

var parentUsed *resources.Resource
parentUsed, err = resources.NewResourceFromConf(map[string]string{"memory": "1012", "vcores": "2"})
assert.NilError(t, err, "failed to create resource: %v", err)
var parent *Queue
parent, err = createManagedQueue(root, "parent", true, nil)
assert.NilError(t, err, "failed to create queue: %v", err)
err = parent.IncAllocatedResource(parentUsed, false)
assert.NilError(t, err, "failed to increment allocated resource: %v", err)

var child1used *resources.Resource
child1used, err = resources.NewResourceFromConf(map[string]string{"memory": "1012", "vcores": "2"})
assert.NilError(t, err, "failed to create resource: %v", err)
var child1 *Queue
child1, err = createManagedQueue(parent, "child1", true, nil)
assert.NilError(t, err, "failed to create queue: %v", err)
err = child1.IncAllocatedResource(child1used, false)
assert.NilError(t, err, "failed to increment allocated resource: %v", err, err)

var child2 *Queue
child2, err = createManagedQueue(parent, "child2", true, nil)
assert.NilError(t, err, "failed to create child queue: %v", err)
child2.SetMaxResource(resources.NewResource())
rootDaoInfo := root.GetQueueInfo()

compareQueueInfoWithDAO(t, root, rootDaoInfo)
parentDaoInfo := rootDaoInfo.ChildQueues[0]
compareQueueInfoWithDAO(t, parent, parentDaoInfo)
for _, childDao := range parentDaoInfo.ChildQueues {
name := childDao.QueueName
child := parent.children[name]
if child == nil {
t.Fail()
}
compareQueueInfoWithDAO(t, child, childDao)
}
}

func TestGetQueueInfoPropertiesSet(t *testing.T) {
root, err := createRootQueue(nil)
assert.NilError(t, err, "failed to create basic root queue: %v", err)

// managed parent queue with property set
properties := map[string]string{configs.ApplicationSortPolicy: "fifo"}
var parent *Queue
parent, err = createManagedQueueWithProps(root, "parent", true, nil, properties)
assert.NilError(t, err, "failed to create queue: %v", err)

// managed leaf queue with some properties set
properties = map[string]string{configs.ApplicationSortPolicy: "fair",
"some_property": "some_value"}
var _ *Queue
_, err = createManagedQueueWithProps(parent, "child1", true, nil, properties)
assert.NilError(t, err, "failed to create queue: %v", err)

// managed leaf queue with some properties set
properties = map[string]string{configs.ApplicationSortPolicy: "state_aware"}
_, err = createManagedQueueWithProps(parent, "child2", true, nil, properties)
assert.NilError(t, err, "failed to create child queue: %v", err)

// dynamic leaf queue picks up from parent
_, err = createDynamicQueue(parent, "child3", true)
assert.NilError(t, err, "failed to create child queue: %v", err)

rootDaoInfo := root.GetQueueInfo()

compareQueueInfoWithDAO(t, root, rootDaoInfo)
parentDaoInfo := rootDaoInfo.ChildQueues[0]
compareQueueInfoWithDAO(t, parent, parentDaoInfo)
for _, childDao := range parentDaoInfo.ChildQueues {
name := childDao.QueueName
child := parent.children[name]
if child == nil {
t.Fail()
}
compareQueueInfoWithDAO(t, child, childDao)
}
}

func compareQueueInfoWithDAO(t *testing.T, queue *Queue, dao dao.QueueDAOInfo) {
assert.Equal(t, queue.Name, dao.QueueName)
assert.Equal(t, len(queue.children), len(dao.ChildQueues))
assert.Equal(t, queue.stateMachine.Current(), dao.Status)
emptyRes := map[string]int64{}
if queue.allocatedResource == nil {
assert.DeepEqual(t, emptyRes, dao.Capacities.UsedCapacity)
} else {
assert.DeepEqual(t, queue.allocatedResource.DAOMap(), dao.Capacities.UsedCapacity)
}
if queue.maxResource == nil {
assert.DeepEqual(t, emptyRes, dao.Capacities.MaxCapacity)
} else {
assert.DeepEqual(t, queue.maxResource.DAOMap(), dao.Capacities.MaxCapacity)
}
if queue.guaranteedResource == nil {
assert.DeepEqual(t, emptyRes, dao.Capacities.Capacity)
} else {
assert.DeepEqual(t, queue.guaranteedResource.DAOMap(), dao.Capacities.Capacity)
}
assert.Equal(t, len(queue.properties), len(dao.Properties))
if len(queue.properties) > 0 {
for k, v := range queue.properties {
assert.Equal(t, v, dao.Properties[k])
}
}
}

func TestSupportTaskGroup(t *testing.T) {
root, err := createRootQueue(nil)
assert.NilError(t, err, "failed to create basic root queue: %v", err)
Expand Down
12 changes: 3 additions & 9 deletions pkg/scheduler/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,11 @@ func (pc *PartitionContext) getQueueInternal(name string) *objects.Queue {
return queue
}

// Get the queue info for the whole queue structure to pass to the webservice
func (pc *PartitionContext) GetQueueInfo() dao.QueueDAOInfo {
return pc.root.GetQueueInfo()
}

// Get the queue info for the whole queue structure to pass to the webservice
func (pc *PartitionContext) GetPartitionQueues() dao.PartitionQueueDAOInfo {
var PartitionQueueDAOInfo = dao.PartitionQueueDAOInfo{}
PartitionQueueDAOInfo = pc.root.GetPartitionQueueDAOInfo()
PartitionQueueDAOInfo.Partition = common.GetPartitionNameWithoutClusterID(pc.Name)
return PartitionQueueDAOInfo
partitionQueueDAOInfo := pc.root.GetPartitionQueueDAOInfo()
partitionQueueDAOInfo.Partition = common.GetPartitionNameWithoutClusterID(pc.Name)
return partitionQueueDAOInfo
}

// Create the recovery queue.
Expand Down