You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by ma...@apache.org on 2024/03/14 05:49:00 UTC

(yunikorn-core) branch master updated: [YUNIKORN-2483] Core: Remove stateaware sort policy (#820)

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 47c3ddcf [YUNIKORN-2483] Core: Remove stateaware sort policy (#820)
47c3ddcf is described below

commit 47c3ddcfca23dd72bb6a58dbba595c709fec716f
Author: Craig Condit <cc...@apache.org>
AuthorDate: Thu Mar 14 11:18:47 2024 +0530

    [YUNIKORN-2483] Core: Remove stateaware sort policy (#820)
    
    Closes: #820
    
    Signed-off-by: Manikandan R <ma...@gmail.com>
---
 pkg/common/configs/config_test.go             |  4 +-
 pkg/scheduler/objects/application.go          |  7 +--
 pkg/scheduler/objects/application_test.go     | 20 -------
 pkg/scheduler/objects/queue.go                | 27 +++------
 pkg/scheduler/objects/queue_test.go           | 79 +++------------------------
 pkg/scheduler/objects/sorters.go              | 44 ---------------
 pkg/scheduler/objects/sorters_test.go         | 65 ----------------------
 pkg/scheduler/partition.go                    |  2 +-
 pkg/scheduler/partition_test.go               | 26 ---------
 pkg/scheduler/policies/sorting_policy.go      | 15 +++--
 pkg/scheduler/policies/sorting_policy_test.go |  4 +-
 pkg/webservice/handlers_test.go               | 10 ++--
 12 files changed, 35 insertions(+), 268 deletions(-)

diff --git a/pkg/common/configs/config_test.go b/pkg/common/configs/config_test.go
index 43c1c10e..e672a202 100644
--- a/pkg/common/configs/config_test.go
+++ b/pkg/common/configs/config_test.go
@@ -45,7 +45,7 @@ partitions:
       - name: root
         submitacl: '*'
         properties:
-          application.sort.policy: stateaware
+          application.sort.policy: fifo
           sample: value2
 `
 
@@ -1714,7 +1714,7 @@ partitions:
       - name: root
         submitacl: '*'
         properties:
-            application.sort.policy: stateaware
+            application.sort.policy: fifo
 `
 	testCases := []struct {
 		name          string
diff --git a/pkg/scheduler/objects/application.go b/pkg/scheduler/objects/application.go
index a064d321..1461a497 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -39,7 +39,6 @@ import (
 	"github.com/apache/yunikorn-core/pkg/metrics"
 	"github.com/apache/yunikorn-core/pkg/rmproxy/rmevent"
 	"github.com/apache/yunikorn-core/pkg/scheduler/ugm"
-	siCommon "github.com/apache/yunikorn-scheduler-interface/lib/go/common"
 	"github.com/apache/yunikorn-scheduler-interface/lib/go/si"
 )
 
@@ -185,11 +184,7 @@ func NewApplication(siApp *si.AddApplicationRequest, ugi security.UserGroup, eve
 	}
 	app.gangSchedulingStyle = gangSchedStyle
 	app.execTimeout = placeholderTimeout
-	if app.GetTag(siCommon.AppTagStateAwareDisable) != "" {
-		app.startTimeout = 0 // transition immediately to Running
-	} else {
-		app.startTimeout = startingTimeout
-	}
+	app.startTimeout = startingTimeout
 	app.user = ugi
 	app.rmEventHandler = eventHandler
 	app.rmID = rmID
diff --git a/pkg/scheduler/objects/application_test.go b/pkg/scheduler/objects/application_test.go
index 04439672..4ddafa0b 100644
--- a/pkg/scheduler/objects/application_test.go
+++ b/pkg/scheduler/objects/application_test.go
@@ -1013,26 +1013,6 @@ func TestStateTimeOut(t *testing.T) {
 	if !app.stateMachine.Is(Running.String()) || app.stateTimer != nil {
 		t.Fatalf("State is not running or timer was not cleared, state: %s, timer %v", app.stateMachine.Current(), app.stateTimer)
 	}
-
-	startingTimeout = time.Minute * 5
-	app = newApplicationWithTags(appID2, "default", "root.a", map[string]string{siCommon.AppTagStateAwareDisable: "true"})
-	err = app.handleApplicationEventWithLocking(RunApplication)
-	assert.NilError(t, err, "no error expected new to accepted (timeout test)")
-	err = app.handleApplicationEventWithLocking(RunApplication)
-	assert.NilError(t, err, "no error expected accepted to starting (timeout test)")
-	// give it some time to run and progress
-	time.Sleep(time.Millisecond * 100)
-	if app.IsStarting() {
-		t.Fatal("Starting state should have timed out")
-	}
-	if app.stateTimer != nil {
-		t.Fatalf("Startup timer has not be cleared on time out as expected, %v", app.stateTimer)
-	}
-	log := app.GetStateLog()
-	assert.Equal(t, len(log), 3, "wrong number of app events")
-	assert.Equal(t, log[0].ApplicationState, Accepted.String())
-	assert.Equal(t, log[1].ApplicationState, Starting.String())
-	assert.Equal(t, log[2].ApplicationState, Running.String())
 }
 
 func TestCompleted(t *testing.T) {
diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index 43c66e8b..d0d8bb2f 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -1126,7 +1126,7 @@ func (sq *Queue) IsPrioritySortEnabled() bool {
 // Only applications with a pending resource request are considered.
 // Lock free call all locks are taken when needed in called functions
 // If withPlaceholdersOnly is true, then only applications with at least one placeholder allocation are considered.
-func (sq *Queue) sortApplications(filterApps, withPlaceholdersOnly bool) []*Application {
+func (sq *Queue) sortApplications(withPlaceholdersOnly bool) []*Application {
 	if !sq.IsLeafQueue() {
 		return nil
 	}
@@ -1144,16 +1144,7 @@ func (sq *Queue) sortApplications(filterApps, withPlaceholdersOnly bool) []*Appl
 	}
 
 	// sort applications based on the sorting policy
-	// some apps might be filtered out based on the policy specific conditions.
-	// currently, only the stateAware policy does the filtering (based on app state).
-	// if the filterApps flag is true, the app filtering is skipped while doing the sorting.
-	queueSortType := sq.getSortType()
-	if !filterApps && queueSortType == policies.StateAwarePolicy {
-		// fallback to FIFO policy if the filterApps flag is false
-		// this is to skip the app filtering in the StateAware policy sorting
-		queueSortType = policies.FifoSortPolicy
-	}
-	return sortApplications(apps, queueSortType, sq.IsPrioritySortEnabled(), sq.GetGuaranteedResource())
+	return sortApplications(apps, sq.getSortType(), sq.IsPrioritySortEnabled(), sq.GetGuaranteedResource())
 }
 
 // sortQueues returns a sorted shallow copy of the queues for this parent queue.
@@ -1360,7 +1351,7 @@ func (sq *Queue) TryAllocate(iterator func() NodeIterator, fullIterator func() N
 		preemptAttemptsRemaining := maxPreemptionsPerQueue
 
 		// process the apps (filters out app without pending requests)
-		for _, app := range sq.sortApplications(true, false) {
+		for _, app := range sq.sortApplications(false) {
 			runnableInQueue := sq.canRunApp(app.ApplicationID)
 			runnableByUserLimit := ugm.GetUserManager().CanRunApp(sq.QueuePath, app.ApplicationID, app.user)
 			app.updateRunnableStatus(runnableInQueue, runnableByUserLimit)
@@ -1402,7 +1393,7 @@ func (sq *Queue) TryAllocate(iterator func() NodeIterator, fullIterator func() N
 func (sq *Queue) TryPlaceholderAllocate(iterator func() NodeIterator, getnode func(string) *Node) *Allocation {
 	if sq.IsLeafQueue() {
 		// process the apps (filters out app without pending requests)
-		for _, app := range sq.sortApplications(true, true) {
+		for _, app := range sq.sortApplications(true) {
 			alloc := app.tryPlaceholderAllocate(iterator, getnode)
 			if alloc != nil {
 				log.Log(log.SchedQueue).Info("allocation found on queue",
@@ -1428,11 +1419,9 @@ func (sq *Queue) TryPlaceholderAllocate(iterator func() NodeIterator, getnode fu
 func (sq *Queue) GetQueueOutstandingRequests(total *[]*AllocationAsk) {
 	if sq.IsLeafQueue() {
 		headRoom := sq.getMaxHeadRoom()
-		// while calculating outstanding requests, we do not need to filter apps.
-		// e.g. StateAware filters apps by state in order to schedule app one by one.
-		// we calculate all the requests that can fit into the queue's headroom,
+		// while calculating outstanding requests, we calculate all the requests that can fit into the queue's headroom,
 		// all these requests are qualified to trigger the up scaling.
-		for _, app := range sq.sortApplications(false, false) {
+		for _, app := range sq.sortApplications(false) {
 			// calculate the users' headroom
 			userHeadroom := ugm.GetUserManager().Headroom(app.queuePath, app.ApplicationID, app.user)
 			app.getOutstandingRequests(headRoom, userHeadroom, total)
@@ -1586,7 +1575,7 @@ func (sq *Queue) getSortType() policies.SortPolicy {
 }
 
 // SupportTaskGroup returns true if the queue supports task groups.
-// FIFO and StateAware sorting policies can support this.
+// FIFO policy is required to support this.
 // NOTE: this call does not make sense for a parent queue, and always returns false
 func (sq *Queue) SupportTaskGroup() bool {
 	sq.RLock()
@@ -1594,7 +1583,7 @@ func (sq *Queue) SupportTaskGroup() bool {
 	if !sq.isLeaf {
 		return false
 	}
-	return sq.sortType == policies.FifoSortPolicy || sq.sortType == policies.StateAwarePolicy
+	return sq.sortType == policies.FifoSortPolicy
 }
 
 // updateGuaranteedResourceMetrics updates guaranteed resource metrics.
diff --git a/pkg/scheduler/objects/queue_test.go b/pkg/scheduler/objects/queue_test.go
index 7c46484e..6947b358 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -647,21 +647,21 @@ func TestSortApplications(t *testing.T) {
 	// empty parent queue
 	parent, err = createManagedQueue(root, "parent", true, nil)
 	assert.NilError(t, err, "failed to create parent queue: %v")
-	if apps := parent.sortApplications(true, false); apps != nil {
+	if apps := parent.sortApplications(false); apps != nil {
 		t.Errorf("parent queue should not return sorted apps: %v", apps)
 	}
 
 	// empty leaf queue
 	leaf, err = createManagedQueue(parent, "leaf", false, nil)
 	assert.NilError(t, err, "failed to create leaf queue")
-	if len(leaf.sortApplications(true, false)) != 0 {
+	if len(leaf.sortApplications(false)) != 0 {
 		t.Errorf("empty queue should return no app from sort: %v", leaf)
 	}
 	// new app does not have pending res, does not get returned
 	app := newApplication(appID1, "default", leaf.QueuePath)
 	app.queue = leaf
 	leaf.AddApplication(app)
-	if len(leaf.sortApplications(true, false)) != 0 {
+	if len(leaf.sortApplications(false)) != 0 {
 		t.Errorf("app without ask should not be in sorted apps: %v", app)
 	}
 	var res *resources.Resource
@@ -670,73 +670,17 @@ func TestSortApplications(t *testing.T) {
 	// add an ask app must be returned
 	err = app.AddAllocationAsk(newAllocationAsk("alloc-1", appID1, res))
 	assert.NilError(t, err, "failed to add allocation ask")
-	sortedApp := leaf.sortApplications(true, false)
+	sortedApp := leaf.sortApplications(false)
 	if len(sortedApp) != 1 || sortedApp[0].ApplicationID != appID1 {
 		t.Errorf("sorted application is missing expected app: %v", sortedApp)
 	}
 	// set 0 repeat
 	_, err = app.UpdateAskRepeat("alloc-1", -1)
-	if err != nil || len(leaf.sortApplications(true, false)) != 0 {
+	if err != nil || len(leaf.sortApplications(false)) != 0 {
 		t.Errorf("app with ask but 0 pending resources should not be in sorted apps: %v (err = %v)", app, err)
 	}
 }
 
-func TestSortApplicationsWithoutFiltering(t *testing.T) {
-	// create the root
-	root, err := createRootQueue(nil)
-	assert.NilError(t, err, "queue create failed")
-
-	var leaf *Queue
-	properties := map[string]string{configs.ApplicationSortPolicy: "stateaware"}
-	leaf, err = createManagedQueueWithProps(root, "leaf", false, nil, properties)
-	assert.NilError(t, err, "failed to create queue: %v", err)
-
-	// new app does not have pending res, does not get returned
-	app1 := newApplication(appID1, "default", leaf.QueuePath)
-	app1.queue = leaf
-	leaf.AddApplication(app1)
-
-	app2 := newApplication(appID2, "default", leaf.QueuePath)
-	app2.queue = leaf
-	leaf.AddApplication(app2)
-
-	// both apps have no pending resource, they will be excluded by the sorting result
-	apps := leaf.sortApplications(true, false)
-	assertAppListLength(t, apps, []string{}, "sort with the filter")
-	apps = leaf.sortApplications(false, false)
-	assertAppListLength(t, apps, []string{}, "sort without the filter")
-
-	// add pending ask to app1
-	var res *resources.Resource
-	res, err = resources.NewResourceFromConf(map[string]string{"first": "1"})
-	assert.NilError(t, err, "failed to create basic resource")
-	// add an ask app must be returned
-	err = app1.AddAllocationAsk(newAllocationAsk("app1-alloc-1", appID1, res))
-	assert.NilError(t, err, "failed to add allocation ask")
-
-	// the sorting result will return app1
-	apps = leaf.sortApplications(true, false)
-	assertAppListLength(t, apps, []string{appID1}, "sort with the filter")
-	apps = leaf.sortApplications(false, false)
-	assertAppListLength(t, apps, []string{appID1}, "sort without the filter")
-
-	// add pending ask to app2
-	res, err = resources.NewResourceFromConf(map[string]string{"first": "1"})
-	assert.NilError(t, err, "failed to create basic resource")
-	// add an ask app must be returned
-	err = app2.AddAllocationAsk(newAllocationAsk("app2-alloc-1", appID2, res))
-	assert.NilError(t, err, "failed to add allocation ask")
-
-	// now there are 2 apps in the queue
-	// according to the state aware policy, if we sort with the filter
-	// only 1 app will be returning in the result; if sort without the filter
-	// it should return the both 2 apps
-	apps = leaf.sortApplications(true, false)
-	assertAppListLength(t, apps, []string{appID1}, "sort with the filter")
-	apps = leaf.sortApplications(false, false)
-	assertAppListLength(t, apps, []string{appID1, appID2}, "sort without the filter")
-}
-
 func TestSortAppsWithPlaceholderAllocations(t *testing.T) {
 	root, err := createRootQueue(nil)
 	assert.NilError(t, err, "queue create failed")
@@ -758,9 +702,7 @@ func TestSortAppsWithPlaceholderAllocations(t *testing.T) {
 	app1.AddAllocation(alloc)
 	err = app1.AddAllocationAsk(newAllocationAsk("ask-0", appID1, res))
 	assert.NilError(t, err, "could not add ask")
-	phApps := leaf.sortApplications(true, true)
-	assert.Equal(t, 1, len(phApps))
-	phApps = leaf.sortApplications(false, true)
+	phApps := leaf.sortApplications(true)
 	assert.Equal(t, 1, len(phApps))
 
 	// adding a placeholder allocation & pending request to "app2"
@@ -769,9 +711,7 @@ func TestSortAppsWithPlaceholderAllocations(t *testing.T) {
 	app2.AddAllocation(alloc2)
 	err = app2.AddAllocationAsk(newAllocationAsk("ask-0", appID1, res))
 	assert.NilError(t, err, "could not add ask")
-	phApps = leaf.sortApplications(true, true)
-	assert.Equal(t, 2, len(phApps))
-	phApps = leaf.sortApplications(false, true)
+	phApps = leaf.sortApplications(true)
 	assert.Equal(t, 2, len(phApps))
 }
 
@@ -1668,11 +1608,6 @@ func TestSupportTaskGroup(t *testing.T) {
 	assert.NilError(t, err, "failed to create queue: %v", err)
 	assert.Assert(t, leaf.SupportTaskGroup(), "leaf queue (FIFO policy) should support task group")
 
-	properties = map[string]string{configs.ApplicationSortPolicy: "StateAware"}
-	leaf, err = createManagedQueueWithProps(parent, "leaf2", false, nil, properties)
-	assert.NilError(t, err, "failed to create queue: %v", err)
-	assert.Assert(t, leaf.SupportTaskGroup(), "leaf queue (StateAware policy) should support task group")
-
 	properties = map[string]string{configs.ApplicationSortPolicy: "fair"}
 	leaf, err = createManagedQueueWithProps(parent, "leaf3", false, nil, properties)
 	assert.NilError(t, err, "failed to create queue: %v", err)
diff --git a/pkg/scheduler/objects/sorters.go b/pkg/scheduler/objects/sorters.go
index eb195e9b..1d7f039b 100644
--- a/pkg/scheduler/objects/sorters.go
+++ b/pkg/scheduler/objects/sorters.go
@@ -113,13 +113,6 @@ func sortApplications(apps map[string]*Application, sortType policies.SortPolicy
 		} else {
 			sortApplicationsBySubmissionTimeAndPriority(sortedApps)
 		}
-	case policies.StateAwarePolicy:
-		sortedApps = stateAwareFilter(apps)
-		if considerPriority {
-			sortApplicationsByPriorityAndSubmissionTime(sortedApps)
-		} else {
-			sortApplicationsBySubmissionTimeAndPriority(sortedApps)
-		}
 	}
 	metrics.GetSchedulerMetrics().ObserveAppSortingLatency(sortingStart)
 	return sortedApps
@@ -192,40 +185,3 @@ func filterOnPendingResources(apps map[string]*Application) []*Application {
 	}
 	return filteredApps
 }
-
-// This filter only allows one (1) application with a state that is not running in the list of candidates.
-// The preference is a state of Starting. If we can not find an app with a starting state we will use an app
-// with an Accepted state. However if there is an app with a Starting state even with no pending resource
-// requests, no Accepted apps can be scheduled. An app in New state does not have any asks and can never be
-// scheduled.
-func stateAwareFilter(apps map[string]*Application) []*Application {
-	filteredApps := make([]*Application, 0)
-	var acceptedApp *Application
-	var foundStarting bool
-	for _, app := range apps {
-		// found a starting app clear out the accepted app (independent of pending resources)
-		if app.IsStarting() {
-			foundStarting = true
-			acceptedApp = nil
-		}
-		// Now just look at app when pending-res > 0
-		if resources.StrictlyGreaterThanZero(app.GetPendingResource()) {
-			// filter accepted apps
-			if app.IsAccepted() {
-				// check if we have not seen a starting app
-				// replace the currently tracked accepted app if this is an older one
-				if !foundStarting && (acceptedApp == nil || acceptedApp.SubmissionTime.After(app.SubmissionTime)) {
-					acceptedApp = app
-				}
-				continue
-			}
-			// this is a running or starting app add it to the list
-			filteredApps = append(filteredApps, app)
-		}
-	}
-	// just add the accepted app if we need to: apps are not sorted yet
-	if acceptedApp != nil {
-		filteredApps = append(filteredApps, acceptedApp)
-	}
-	return filteredApps
-}
diff --git a/pkg/scheduler/objects/sorters_test.go b/pkg/scheduler/objects/sorters_test.go
index 10ed5a6c..aaa3951a 100644
--- a/pkg/scheduler/objects/sorters_test.go
+++ b/pkg/scheduler/objects/sorters_test.go
@@ -174,11 +174,6 @@ func TestSortAppsNoPending(t *testing.T) {
 	list = sortApplications(input, policies.FifoSortPolicy, true, nil)
 	assertAppListLength(t, list, []string{}, "fifo no pending - priority")
 
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	assertAppListLength(t, list, []string{}, "state no pending")
-	list = sortApplications(input, policies.StateAwarePolicy, true, nil)
-	assertAppListLength(t, list, []string{}, "state no pending - priority")
-
 	// set one app with pending
 	appID := "app-1"
 	input[appID].pending = res
@@ -191,11 +186,6 @@ func TestSortAppsNoPending(t *testing.T) {
 	assertAppListLength(t, list, []string{appID}, "fifo one pending")
 	list = sortApplications(input, policies.FifoSortPolicy, true, nil)
 	assertAppListLength(t, list, []string{appID}, "fifo one pending - priority")
-
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	assertAppListLength(t, list, []string{appID}, "state one pending")
-	list = sortApplications(input, policies.StateAwarePolicy, true, nil)
-	assertAppListLength(t, list, []string{appID}, "state one pending - priority")
 }
 
 func TestSortAppsFifo(t *testing.T) {
@@ -332,61 +322,6 @@ func TestSortAppsPriorityFair(t *testing.T) {
 	assertAppList(t, list, []int{2, 0, 3, 1}, "app-1 & app-3 allocated")
 }
 
-func TestSortAppsStateAware(t *testing.T) {
-	// stable sort is used so equal values stay where they were
-	res := resources.NewResourceFromMap(map[string]resources.Quantity{
-		"vcore": resources.Quantity(100)})
-	// setup all apps with pending resources, all accepted state
-	input := make(map[string]*Application, 4)
-	for i := 0; i < 4; i++ {
-		num := strconv.Itoa(i)
-		appID := "app-" + num
-		app := newApplication(appID, "partition", "queue")
-		app.pending = res
-		input[appID] = app
-		err := app.HandleApplicationEvent(RunApplication)
-		assert.NilError(t, err, "state change failed for app %v", appID)
-		// make sure the time stamps differ at least a bit (tracking in nano seconds)
-		time.Sleep(time.Nanosecond * 5)
-	}
-	// only first app should be returned (all in accepted)
-	list := sortApplications(input, policies.StateAwarePolicy, false, nil)
-	appID0 := "app-0"
-	assertAppListLength(t, list, []string{appID0}, "state all accepted")
-
-	// set first app pending to zero, should get 2nd app back
-	input[appID0].pending = resources.NewResource()
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	appID1 := "app-1"
-	assertAppListLength(t, list, []string{appID1}, "state no pending")
-
-	// move the first app to starting no pending resource should get nothing
-	err := input[appID0].HandleApplicationEvent(RunApplication)
-	assert.NilError(t, err, "state change failed for app-0")
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	assertAppListLength(t, list, []string{}, "state starting no pending")
-
-	// move first app to running (no pending resource) and 4th app to starting should get starting app
-	err = input[appID0].HandleApplicationEvent(RunApplication)
-	assert.NilError(t, err, "state change failed for app-0")
-	appID3 := "app-3"
-	err = input[appID3].HandleApplicationEvent(RunApplication)
-	assert.NilError(t, err, "state change failed for app-3")
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	assertAppListLength(t, list, []string{appID3}, "state starting")
-
-	// set pending for first app, should get back 1st and 4th in that order
-	input[appID0].pending = res
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	assertAppListLength(t, list, []string{appID0, appID3}, "state first pending")
-
-	// move 4th to running should get back: 1st, 2nd and 4th in that order
-	err = input[appID3].HandleApplicationEvent(RunApplication)
-	assert.NilError(t, err, "state change failed for app-3")
-	list = sortApplications(input, policies.StateAwarePolicy, false, nil)
-	assertAppListLength(t, list, []string{appID0, appID1, appID3}, "state not app-2")
-}
-
 func queueNames(list []*Queue) string {
 	result := make([]string, 0)
 	for _, v := range list {
diff --git a/pkg/scheduler/partition.go b/pkg/scheduler/partition.go
index c318c6b8..26ae861c 100644
--- a/pkg/scheduler/partition.go
+++ b/pkg/scheduler/partition.go
@@ -345,7 +345,7 @@ func (pc *PartitionContext) AddApplication(app *objects.Application) error {
 	queue.AddApplication(app)
 	// check only for gang request
 	// - make sure the taskgroup request fits in the maximum set for the queue hierarchy
-	// - task groups should only be used in FIFO or StateAware queues
+	// - task groups should only be used in FIFO queues
 	// if the check fails remove the app from the queue again
 	if placeHolder := app.GetPlaceholderAsk(); !resources.IsZero(placeHolder) {
 		// check the queue sorting
diff --git a/pkg/scheduler/partition_test.go b/pkg/scheduler/partition_test.go
index 14bef767..f1f0de89 100644
--- a/pkg/scheduler/partition_test.go
+++ b/pkg/scheduler/partition_test.go
@@ -1064,32 +1064,6 @@ func TestAddAppTaskGroup(t *testing.T) {
 	if err == nil || partition.getApplication(appID2) != nil {
 		t.Errorf("add application should have failed due to queue sort policy but did not")
 	}
-
-	// queue with stateaware as sort policy, with a max set smaller than placeholder ask: app add should fail
-	err = queue.ApplyConf(configs.QueueConfig{
-		Name:       "default",
-		Parent:     false,
-		Queues:     nil,
-		Properties: map[string]string{configs.ApplicationSortPolicy: "stateaware"},
-		Resources:  configs.Resources{Max: map[string]string{"vcore": "5"}},
-	})
-	assert.NilError(t, err, "updating queue should not have failed (stateaware & max)")
-	queue.UpdateQueueProperties()
-	err = partition.AddApplication(app)
-	if err == nil || partition.getApplication(appID2) != nil {
-		t.Errorf("add application should have failed due to max queue resource but did not")
-	}
-
-	// queue with stateaware as sort policy, with a max set larger than placeholder ask: app add works
-	err = queue.ApplyConf(configs.QueueConfig{
-		Name:      "default",
-		Parent:    false,
-		Queues:    nil,
-		Resources: configs.Resources{Max: map[string]string{"vcore": "20"}},
-	})
-	assert.NilError(t, err, "updating queue should not have failed (max resource)")
-	err = partition.AddApplication(app)
-	assert.NilError(t, err, "add application to partition should not have failed")
 }
 
 func TestRemoveApp(t *testing.T) {
diff --git a/pkg/scheduler/policies/sorting_policy.go b/pkg/scheduler/policies/sorting_policy.go
index 99e017c6..f53cb36f 100644
--- a/pkg/scheduler/policies/sorting_policy.go
+++ b/pkg/scheduler/policies/sorting_policy.go
@@ -20,16 +20,18 @@ package policies
 
 import (
 	"fmt"
+
+	"github.com/apache/yunikorn-core/pkg/log"
 )
 
 // Sort type for queues & apps.
 type SortPolicy int
 
 const (
-	FifoSortPolicy   SortPolicy = iota // first in first out, submit time
-	FairSortPolicy                     // fair based on usage
-	StateAwarePolicy                   // only 1 app in starting state
-	Undefined                          // not initialised or parsing failed
+	FifoSortPolicy             SortPolicy = iota // first in first out, submit time
+	FairSortPolicy                               // fair based on usage
+	deprecatedStateAwarePolicy                   // deprecated: now alias for FIFO
+	Undefined                                    // not initialised or parsing failed
 )
 
 func (s SortPolicy) String() string {
@@ -43,8 +45,9 @@ func SortPolicyFromString(str string) (SortPolicy, error) {
 		return FifoSortPolicy, nil
 	case FairSortPolicy.String():
 		return FairSortPolicy, nil
-	case StateAwarePolicy.String():
-		return StateAwarePolicy, nil
+	case deprecatedStateAwarePolicy.String():
+		log.Log(log.Deprecation).Warn("Sort policy 'stateaware' is deprecated; using 'fifo' instead")
+		return FifoSortPolicy, nil
 	default:
 		return Undefined, fmt.Errorf("undefined policy: %s", str)
 	}
diff --git a/pkg/scheduler/policies/sorting_policy_test.go b/pkg/scheduler/policies/sorting_policy_test.go
index 1900d34b..07b29408 100644
--- a/pkg/scheduler/policies/sorting_policy_test.go
+++ b/pkg/scheduler/policies/sorting_policy_test.go
@@ -32,7 +32,7 @@ func TestAppFromString(t *testing.T) {
 		{"EmptyString", "", FifoSortPolicy, false},
 		{"FifoString", "fifo", FifoSortPolicy, false},
 		{"FairString", "fair", FairSortPolicy, false},
-		{"StatusString", "stateaware", StateAwarePolicy, false},
+		{"StatusString", "stateaware", FifoSortPolicy, false},
 		{"UnknownString", "unknown", Undefined, true},
 	}
 	for _, tt := range tests {
@@ -56,7 +56,7 @@ func TestAppToString(t *testing.T) {
 	}{
 		{"FifoString", FifoSortPolicy, "fifo"},
 		{"FairString", FairSortPolicy, "fair"},
-		{"StatusString", StateAwarePolicy, "stateaware"},
+		{"StatusString", deprecatedStateAwarePolicy, "stateaware"},
 		{"DefaultString", Undefined, "undefined"},
 		{"NoneString", someSP, "fifo"},
 	}
diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index 6745ce16..6b0f8a90 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -142,11 +142,11 @@ partitions:
       - 
         name: root
         properties:
-          application.sort.policy: stateaware
+          application.sort.policy: fifo
         childtemplate:
           maxapplications: 10
           properties:
-            application.sort.policy: stateaware
+            application.sort.policy: fifo
           resources:
             guaranteed:
               memory: 400000
@@ -1058,7 +1058,7 @@ func TestGetPartitionQueuesHandler(t *testing.T) {
 		MaxResource:        tMaxResource.DAOMap(),
 		GuaranteedResource: tGuaranteedResource.DAOMap(),
 		Properties: map[string]string{
-			configs.ApplicationSortPolicy: policies.StateAwarePolicy.String(),
+			configs.ApplicationSortPolicy: policies.FifoSortPolicy.String(),
 		},
 	}
 
@@ -1095,7 +1095,7 @@ func TestGetPartitionQueuesHandler(t *testing.T) {
 	assert.Equal(t, partitionQueuesDao.CurrentPriority, configs.MinPriority)
 	assert.Assert(t, partitionQueuesDao.AllocatingAcceptedApps == nil)
 	assert.Equal(t, len(partitionQueuesDao.Properties), 1)
-	assert.Equal(t, partitionQueuesDao.Properties[configs.ApplicationSortPolicy], policies.StateAwarePolicy.String())
+	assert.Equal(t, partitionQueuesDao.Properties[configs.ApplicationSortPolicy], policies.FifoSortPolicy.String())
 	assert.DeepEqual(t, partitionQueuesDao.TemplateInfo, &templateInfo)
 
 	// assert child root.a fields
@@ -1119,7 +1119,7 @@ func TestGetPartitionQueuesHandler(t *testing.T) {
 	assert.Equal(t, child.CurrentPriority, configs.MinPriority)
 	assert.Assert(t, child.AllocatingAcceptedApps == nil)
 	assert.Equal(t, len(child.Properties), 1)
-	assert.Equal(t, child.Properties[configs.ApplicationSortPolicy], policies.StateAwarePolicy.String())
+	assert.Equal(t, child.Properties[configs.ApplicationSortPolicy], policies.FifoSortPolicy.String())
 	assert.DeepEqual(t, child.TemplateInfo, &templateInfo)
 
 	// assert child root.a.a1 fields


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org