This is an automated email from the ASF dual-hosted git repository.

pbacsko 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 a9dcab4b [YUNIKORN-2175] Add queue headRoom for Rest API querying 
(#727)
a9dcab4b is described below

commit a9dcab4bf48ce95b1fe566327d15dfda7742d60b
Author: qzhu <[email protected]>
AuthorDate: Thu Nov 23 17:23:51 2023 +0100

    [YUNIKORN-2175] Add queue headRoom for Rest API querying (#727)
    
    Closes: #727
    
    Signed-off-by: Peter Bacsko <[email protected]>
---
 pkg/scheduler/objects/application.go             | 3 +--
 pkg/scheduler/objects/application_events.go      | 7 ++++---
 pkg/scheduler/objects/application_events_test.go | 7 ++++---
 pkg/scheduler/objects/queue.go                   | 1 +
 pkg/scheduler/objects/queue_test.go              | 5 +++--
 pkg/webservice/dao/queue_info.go                 | 1 +
 6 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/pkg/scheduler/objects/application.go 
b/pkg/scheduler/objects/application.go
index 3e27613d..caa0a162 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -994,8 +994,7 @@ func (sa *Application) tryAllocate(headRoom 
*resources.Resource, allowPreemption
                                        }
                                }
                        }
-
-                       sa.appEvents.sendAppDoesNotFitEvent(request)
+                       sa.appEvents.sendAppDoesNotFitEvent(request, headRoom)
                        continue
                }
 
diff --git a/pkg/scheduler/objects/application_events.go 
b/pkg/scheduler/objects/application_events.go
index 56100290..35fc34cc 100644
--- a/pkg/scheduler/objects/application_events.go
+++ b/pkg/scheduler/objects/application_events.go
@@ -25,6 +25,7 @@ import (
        "golang.org/x/time/rate"
 
        "github.com/apache/yunikorn-core/pkg/common"
+       "github.com/apache/yunikorn-core/pkg/common/resources"
        "github.com/apache/yunikorn-core/pkg/events"
        "github.com/apache/yunikorn-scheduler-interface/lib/go/si"
 )
@@ -35,11 +36,11 @@ type applicationEvents struct {
        limiter     *rate.Limiter
 }
 
-func (evt *applicationEvents) sendAppDoesNotFitEvent(request *AllocationAsk) {
+func (evt *applicationEvents) sendAppDoesNotFitEvent(request *AllocationAsk, 
headroom *resources.Resource) {
        if !evt.eventSystem.IsEventTrackingEnabled() || !evt.limiter.Allow() {
                return
        }
-       message := fmt.Sprintf("Application %s does not fit into %s queue", 
request.GetApplicationID(), evt.app.queuePath)
+       message := fmt.Sprintf("Application %s does not fit into %s queue 
(request resoure %s, headroom %s)", request.GetApplicationID(), 
evt.app.queuePath, request.GetAllocatedResource(), headroom)
        event := events.CreateRequestEventRecord(request.GetAllocationKey(), 
request.GetApplicationID(), message, request.GetAllocatedResource())
        evt.eventSystem.AddEvent(event)
 }
@@ -48,7 +49,7 @@ func (evt *applicationEvents) sendPlaceholderLargerEvent(ph 
*Allocation, request
        if !evt.eventSystem.IsEventTrackingEnabled() {
                return
        }
-       message := fmt.Sprintf("Task group '%s' in application '%s': allocation 
resources '%s' are not matching placeholder '%s' allocation with ID '%s'", 
ph.GetTaskGroup(), evt.app.ApplicationID, 
request.GetAllocatedResource().String(), ph.GetAllocatedResource().String(), 
ph.GetAllocationKey())
+       message := fmt.Sprintf("Task group '%s' in application '%s': allocation 
resources '%s' are not matching placeholder '%s' allocation with ID '%s'", 
ph.GetTaskGroup(), evt.app.ApplicationID, request.GetAllocatedResource(), 
ph.GetAllocatedResource(), ph.GetAllocationKey())
        event := events.CreateRequestEventRecord(ph.GetAllocationKey(), 
evt.app.ApplicationID, message, request.GetAllocatedResource())
        evt.eventSystem.AddEvent(event)
 }
diff --git a/pkg/scheduler/objects/application_events_test.go 
b/pkg/scheduler/objects/application_events_test.go
index 9d72a8bc..3ddf4f9c 100644
--- a/pkg/scheduler/objects/application_events_test.go
+++ b/pkg/scheduler/objects/application_events_test.go
@@ -25,6 +25,7 @@ import (
        "gotest.tools/v3/assert"
 
        "github.com/apache/yunikorn-core/pkg/common"
+       "github.com/apache/yunikorn-core/pkg/common/resources"
        "github.com/apache/yunikorn-scheduler-interface/lib/go/si"
 )
 
@@ -55,7 +56,7 @@ func TestSendAppDoesNotFitEvent(t *testing.T) {
        }
        mock := newEventSystemMockDisabled()
        appEvents := newApplicationEvents(app, mock)
-       appEvents.sendAppDoesNotFitEvent(&AllocationAsk{})
+       appEvents.sendAppDoesNotFitEvent(&AllocationAsk{}, 
&resources.Resource{})
        assert.Equal(t, 0, len(mock.events), "unexpected event")
 
        mock = newEventSystemMock()
@@ -63,7 +64,7 @@ func TestSendAppDoesNotFitEvent(t *testing.T) {
        appEvents.sendAppDoesNotFitEvent(&AllocationAsk{
                applicationID: appID0,
                allocationKey: aKey,
-       })
+       }, &resources.Resource{})
        assert.Equal(t, 1, len(mock.events), "event was not generated")
 }
 
@@ -82,7 +83,7 @@ func TestSendAppDoesNotFitEventWithRateLimiter(t *testing.T) {
                appEvents.sendAppDoesNotFitEvent(&AllocationAsk{
                        applicationID: appID0,
                        allocationKey: aKey,
-               })
+               }, &resources.Resource{})
                time.Sleep(10 * time.Millisecond)
        }
        assert.Equal(t, 1, len(mock.events), "event was not generated")
diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index e7eb293c..afe9fad6 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -642,6 +642,7 @@ func (sq *Queue) GetPartitionQueueDAOInfo() 
dao.PartitionQueueDAOInfo {
        queueInfo.GuaranteedResource = sq.guaranteedResource.DAOMap()
        queueInfo.AllocatedResource = sq.allocatedResource.DAOMap()
        queueInfo.PreemptingResource = sq.preemptingResource.DAOMap()
+       queueInfo.HeadRoom = sq.getHeadRoom().DAOMap()
        queueInfo.IsLeaf = sq.isLeaf
        queueInfo.IsManaged = sq.isManaged
        queueInfo.CurrentPriority = sq.getCurrentPriority()
diff --git a/pkg/scheduler/objects/queue_test.go 
b/pkg/scheduler/objects/queue_test.go
index 13306019..b0d32b65 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -1708,8 +1708,9 @@ func TestGetPartitionQueueDAOInfo(t *testing.T) {
        // test resources
        root.maxResource = getResource(t)
        root.guaranteedResource = getResource(t)
-       assert.DeepEqual(t, root.GetMaxResource().DAOMap(), 
root.GetMaxResource().DAOMap())
-       assert.DeepEqual(t, root.GetGuaranteedResource().DAOMap(), 
root.GetGuaranteedResource().DAOMap())
+       assert.DeepEqual(t, root.GetMaxResource().DAOMap(), 
root.GetPartitionQueueDAOInfo().MaxResource)
+       assert.DeepEqual(t, root.GetGuaranteedResource().DAOMap(), 
root.GetPartitionQueueDAOInfo().GuaranteedResource)
+       assert.DeepEqual(t, root.getHeadRoom().DAOMap(), 
root.GetPartitionQueueDAOInfo().HeadRoom)
 
        // test allocatingAcceptedApps
        root.allocatingAcceptedApps = getAllocatingAcceptedApps()
diff --git a/pkg/webservice/dao/queue_info.go b/pkg/webservice/dao/queue_info.go
index a1e3da21..2c2ee250 100644
--- a/pkg/webservice/dao/queue_info.go
+++ b/pkg/webservice/dao/queue_info.go
@@ -33,6 +33,7 @@ type PartitionQueueDAOInfo struct {
        GuaranteedResource     map[string]int64        
`json:"guaranteedResource,omitempty"`
        AllocatedResource      map[string]int64        
`json:"allocatedResource,omitempty"`
        PreemptingResource     map[string]int64        
`json:"preemptingResource,omitempty"`
+       HeadRoom               map[string]int64        
`json:"headroom,omitempty"`
        IsLeaf                 bool                    `json:"isLeaf"`    // no 
omitempty, a false value gives a quick way to understand whether it's leaf.
        IsManaged              bool                    `json:"isManaged"` // no 
omitempty, a false value gives a quick way to understand whether it's managed.
        Properties             map[string]string       
`json:"properties,omitempty"`


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to