This is an automated email from the ASF dual-hosted git repository.
mani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new 12d927c5 [YUNIKORN-1986] add ugm CanRunApp to TryReservedAllocate
(#650)
12d927c5 is described below
commit 12d927c53660449c1bb84b32a5138fb0d21a5344
Author: PoAn Yang <[email protected]>
AuthorDate: Tue Sep 19 11:43:32 2023 +0530
[YUNIKORN-1986] add ugm CanRunApp to TryReservedAllocate (#650)
Closes: #650
Signed-off-by: Manikandan R <[email protected]>
---
pkg/scheduler/objects/queue.go | 2 +-
pkg/scheduler/partition_test.go | 160 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 161 insertions(+), 1 deletion(-)
diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index 7eb01b89..58bc3574 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -1435,7 +1435,7 @@ func (sq *Queue) TryReservedAllocate(iterator func()
NodeIterator) *Allocation {
zap.String("appID", appID))
return nil
}
- if app.IsAccepted() && !sq.canRunApp(appID) {
+ if app.IsAccepted() && (!sq.canRunApp(appID) ||
!ugm.GetUserManager().CanRunApp(sq.QueuePath, appID, app.user)) {
continue
}
alloc := app.tryReservedAllocate(headRoom,
iterator)
diff --git a/pkg/scheduler/partition_test.go b/pkg/scheduler/partition_test.go
index 8f81d88f..59e91f86 100644
--- a/pkg/scheduler/partition_test.go
+++ b/pkg/scheduler/partition_test.go
@@ -3902,3 +3902,163 @@ func TestLimitMaxApplications(t *testing.T) {
})
}
}
+
+//nolint:funlen
+func TestLimitMaxApplicationsForReservedAllocation(t *testing.T) {
+ testCases := []struct {
+ name string
+ limits []configs.Limit
+ }{
+ {
+ name: "specific user",
+ limits: []configs.Limit{
+ {
+ Limit: "specific user limit",
+ Users: []string{"testuser"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 1,
+ },
+ },
+ },
+ {
+ name: "specific group",
+ limits: []configs.Limit{
+ {
+ Limit: "specific group limit",
+ Groups: []string{"testgroup"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 1,
+ },
+ },
+ },
+ {
+ name: "wildcard user",
+ limits: []configs.Limit{
+ {
+ Limit: "wildcard user limit",
+ Users: []string{"*"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 1,
+ },
+ },
+ },
+ {
+ name: "wildcard group",
+ limits: []configs.Limit{
+ {
+ Limit: "specific group limit",
+ Groups:
[]string{"nonexistent-group"},
+ MaxResources:
map[string]string{"memory": "500", "vcores": "500"},
+ MaxApplications: 100,
+ },
+ {
+ Limit: "wildcard group limit",
+ Groups: []string{"*"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 1,
+ },
+ },
+ },
+ {
+ name: "specific user lower than specific group limit",
+ limits: []configs.Limit{
+ {
+ Limit: "specific user limit",
+ Users: []string{"testuser"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 1,
+ },
+ {
+ Limit: "specific user limit",
+ Groups: []string{"testgroup"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 100,
+ },
+ },
+ },
+ {
+ name: "specific group lower than specific user limit",
+ limits: []configs.Limit{
+ {
+ Limit: "specific user limit",
+ Users: []string{"testuser"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 100,
+ },
+ {
+ Limit: "specific group limit",
+ Groups: []string{"testgroup"},
+ MaxResources:
map[string]string{"memory": "5", "vcores": "5"},
+ MaxApplications: 1,
+ },
+ },
+ },
+ }
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ setupUGM()
+ conf := configs.PartitionConfig{
+ Name: "default",
+ Queues: []configs.QueueConfig{
+ {
+ Name: "root",
+ Parent: true,
+ SubmitACL: "*",
+ Queues: []configs.QueueConfig{
+ {
+ Name:
"default",
+ Parent: false,
+ Limits:
tc.limits,
+ },
+ },
+ },
+ },
+ NodeSortPolicy: configs.NodeSortingPolicy{},
+ }
+
+ partition, err := newPartitionContext(conf, rmID, nil)
+ assert.NilError(t, err, "partition create failed")
+
+ // add node1
+ nodeRes, err :=
resources.NewResourceFromConf(map[string]string{"memory": "10", "vcores": "10"})
+ assert.NilError(t, err, "failed to create basic
resource")
+ node := newNodeMaxResource("node-1", nodeRes)
+ err = partition.AddNode(node, nil)
+ assert.NilError(t, err, "test node1 add failed
unexpected")
+
+ resMap := map[string]string{"memory": "2", "vcores":
"2"}
+ res, err := resources.NewResourceFromConf(resMap)
+ assert.NilError(t, err, "Unexpected error when creating
resource from map")
+
+ // add app1
+ app1 := newApplication(appID1, "default", defQueue)
+ err = partition.AddApplication(app1)
+ assert.NilError(t, err, "add application to partition
should not have failed")
+ app1AllocAsk := newAllocationAsk(allocID, appID1, res)
+ err = app1.AddAllocationAsk(app1AllocAsk)
+ assert.NilError(t, err, "failed to add ask alloc-1 to
app-1")
+
+ partition.reserve(app1, node, app1AllocAsk)
+ alloc := partition.tryReservedAllocate()
+ if alloc == nil {
+ t.Fatal("allocation did not return any
allocation")
+ }
+ assert.Equal(t, alloc.GetResult(),
objects.AllocatedReserved, "result is not the expected allocated reserved")
+ assert.Equal(t, alloc.GetApplicationID(), appID1,
"expected application app-1 to be allocated reserved")
+ assert.Equal(t, alloc.GetAllocationKey(), allocID,
"expected ask alloc-1 to be allocated reserved")
+
+ // add app2
+ app2 := newApplication(appID2, "default", defQueue)
+ err = partition.AddApplication(app2)
+ assert.NilError(t, err, "add application to partition
should not have failed")
+ app2AllocAsk := newAllocationAsk(allocID2, appID2, res)
+ err = app2.AddAllocationAsk(app2AllocAsk)
+ assert.NilError(t, err, "failed to add ask alloc-2 to
app-1")
+ assert.Equal(t, app2.CurrentState(),
objects.Accepted.String(), "application should have moved to accepted state")
+
+ partition.reserve(app2, node, app2AllocAsk)
+ alloc = partition.tryReservedAllocate()
+ assert.Equal(t, alloc == nil, true, "allocation should
not have happened as max apps reached")
+ })
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]