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 80c3788e [YUNIKORN-1919] decrease runningApps when app changes from
starting to completing (#619)
80c3788e is described below
commit 80c3788e873da1fdbeee94e53837d013647d04fc
Author: Frank Yang <[email protected]>
AuthorDate: Thu Aug 17 16:44:50 2023 +0530
[YUNIKORN-1919] decrease runningApps when app changes from starting to
completing (#619)
Closes: #619
Signed-off-by: Manikandan R <[email protected]>
---
pkg/scheduler/objects/application_state.go | 5 +++++
pkg/scheduler/objects/queue_test.go | 35 ++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/pkg/scheduler/objects/application_state.go
b/pkg/scheduler/objects/application_state.go
index aef19048..98961884 100644
--- a/pkg/scheduler/objects/application_state.go
+++ b/pkg/scheduler/objects/application_state.go
@@ -162,6 +162,11 @@ func NewAppState() *fsm.FSM {
},
fmt.Sprintf("enter_%s", Completing.String()): func(_
context.Context, event *fsm.Event) {
app := event.Args[0].(*Application)
//nolint:errcheck
+ if event.Src == Starting.String() {
+ app.queue.decRunningApps()
+
metrics.GetQueueMetrics(app.queuePath).DecQueueApplicationsRunning()
+
metrics.GetSchedulerMetrics().DecTotalApplicationsRunning()
+ }
app.setStateTimer(completingTimeout,
app.stateMachine.Current(), CompleteApplication)
app.appEvents.sendStateChangeEvent(si.EventRecord_APP_COMPLETING)
},
diff --git a/pkg/scheduler/objects/queue_test.go
b/pkg/scheduler/objects/queue_test.go
index 62d08102..dceb138a 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -2639,3 +2639,38 @@ func TestQueueEvents(t *testing.T) {
assert.Equal(t, si.EventRecord_SET, records[2].EventChangeType)
assert.Equal(t, si.EventRecord_QUEUE_GUARANTEED,
records[2].EventChangeDetail)
}
+
+func TestQueueRunningAppsForSingleAllocationApp(t *testing.T) {
+ // create the root
+ root, err := createRootQueue(nil)
+ assert.NilError(t, err, "queue create failed")
+
+ // single leaf under root
+ var leaf *Queue
+ leaf, err = createManagedQueue(root, "leaf", false, nil)
+ assert.NilError(t, err, "failed to create leaf queue")
+
+ app := newApplication(appID1, "default", "root.leaf")
+ app.SetQueue(leaf)
+ leaf.AddApplication(app)
+
+ var res *resources.Resource
+ res, err = resources.NewResourceFromConf(map[string]string{"first":
"1"})
+ assert.NilError(t, err, "failed to create basic resource")
+
+ ask := newAllocationAsk("ask-1", appID1, res)
+ err = app.AddAllocationAsk(ask)
+ assert.NilError(t, err, "failed to add ask")
+
+ alloc := NewAllocation("alloc-1", nodeID1, ask)
+ app.AddAllocation(alloc)
+ assert.Equal(t, app.CurrentState(), Starting.String(), "app state
should be starting")
+ assert.Equal(t, leaf.runningApps, uint64(1), "leaf should have 1 app
running")
+
+ _, err = app.updateAskRepeatInternal(ask, -1)
+ assert.NilError(t, err, "failed to decrease pending resources")
+
+ app.RemoveAllocation(alloc.GetUUID(), si.TerminationType_STOPPED_BY_RM)
+ assert.Equal(t, app.CurrentState(), Completing.String(), "app state
should be completing")
+ assert.Equal(t, leaf.runningApps, uint64(0), "leaf should have 0 app
running")
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]