wilfred-s commented on a change in pull request #173:
URL:
https://github.com/apache/incubator-yunikorn-core/pull/173#discussion_r444242859
##########
File path: go.mod
##########
@@ -51,3 +51,5 @@ require (
gotest.tools v2.2.0+incompatible
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
)
+
+replace github.com/apache/incubator-yunikorn-scheduler-interface =>
/Users/wyang/workspace/github/wyang/incubator-yunikorn-scheduler-interface
Review comment:
This is causing the build to fail, please remove
##########
File path: pkg/scheduler/scheduling_queue_test.go
##########
@@ -688,11 +692,295 @@ func TestHeadroom(t *testing.T) {
res, err = resources.NewResourceFromConf(map[string]string{"first":
"10", "second": "2"})
assert.NilError(t, err, "failed to create resource")
headRoom = leaf1.getHeadRoom()
- if !resources.Equals(res, headRoom) {
+ maxHeadRoom = leaf1.getMaxHeadRoom()
+ if !resources.Equals(res, headRoom) || !resources.Equals(res,
maxHeadRoom) {
t.Errorf("leaf1 queue head room not as expected %v, got: %v
(err %v)", res, headRoom, err)
}
headRoom = leaf2.getHeadRoom()
+ maxHeadRoom = leaf2.getMaxHeadRoom()
+ if !resources.Equals(res, headRoom) || !resources.Equals(res,
maxHeadRoom) {
+ t.Errorf("leaf1 queue head room not as expected %v, got: %v
(err %v)", res, headRoom, err)
+ }
+}
+
+func TestMaxHeadroom(t *testing.T) {
+ // create the root: nil test
Review comment:
I am missing tests with a maxResource set on the root queue.
You can set it on the root queue via the `qi.setMaxResource()`
##########
File path: pkg/plugins/plugins.go
##########
@@ -50,6 +50,12 @@ func RegisterSchedulerPlugin(plugin interface{}) {
plugins.reconcilePlugin = t
registered = true
}
+ if t, ok := plugin.(ContainerSchedulingStateUpdater); ok {
+ log.Logger().Debug("register scheduler plugin",
+ zap.String("type", "ContainerSchedulingStateUpdater"))
Review comment:
This is just a fixed string we should not split that over 2 lines.
It really needs to be fixed for all log entries.
We also should move to a type switch to simplify and clarify this code:
```
switch p := plugin.(type) {
case PredicatesPlugin:
plugins.predicatesPlugin = p
case VolumesPlugin:
plugins.volumesPlugin = p
}
```
##########
File path: pkg/scheduler/scheduling_application.go
##########
@@ -418,12 +431,34 @@ func (sa *SchedulingApplication) tryAllocate(headRoom
*resources.Resource, ctx *
for _, request := range sa.sortedRequests {
// resource must fit in headroom otherwise skip the request
if !resources.FitIn(headRoom, request.AllocatedResource) {
+ // if the queue (or any of its parent) has max capacity
is defined,
+ // get the max headroom, this represents the configured
queue quota.
+ // if queue quota is enough, but headroom is not,
usually this means
+ // the cluster needs to scale up to meet the its
capacity.
+ maxHeadRoom := sa.queue.getMaxHeadRoom()
+ if resources.FitIn(maxHeadRoom,
request.AllocatedResource) {
+
sa.updateContainerSchedulingStateIfNeeded(request,
+
si.UpdateContainerSchedulingStateRequest_FAILED,
+ "failed to schedule the request because
partition resource is not enough")
+ }
+ // skip the request
continue
}
if nodeIterator := ctx.getNodeIterator(); nodeIterator != nil {
alloc := sa.tryNodes(request, nodeIterator)
- // have a candidate return it
- if alloc != nil {
+ if alloc == nil {
+ // we have enough headroom, but we could not
find a node for this request,
+ // this can happen when non of the nodes is
qualified for this request,
+ // by satisfying both conditions:
+ // 1) node has enough resources;
+ // 2) node satisfies all placement
constraints of the request (e.g predicates)
Review comment:
This might not be correct, see the lines around 578 in
scheduling_application.go:
```
if !nodeToReserve.preReserveConditions(allocKey) {
return nil
}
```
We might have looked at all nodes but failed to reserve a node because of
predicates.
The other case is that we have a new request which did not trigger the
reservation threshold.
We should trigger the upscale in line with the reservation logic I think.
##########
File path: pkg/scheduler/scheduling_queue.go
##########
@@ -499,6 +499,37 @@ func (sq *SchedulingQueue) getHeadRoom()
*resources.Resource {
return resources.ComponentWiseMin(headRoom, parentHeadRoom)
}
+// this function returns the max headRoom of a queue
+// this doesn't get the partition resources into the consideration
+func (sq *SchedulingQueue) getMaxHeadRoom() *resources.Resource {
Review comment:
The getMaxHeadRoom and getHeadRoom share most of the code.
Can we simplify this by taking the recursive code out for the two different
calculations:
```
func (sq *SchedulingQueue) getHeadRoom() *resources.Resource {
var parentHeadRoom *resources.Resource
if sq.parent != nil {
parentHeadRoom = sq.parent.getHeadRoom()
}
return sq.internalHeadRoom(parentHeadRoom)
}
func (sq *SchedulingQueue) getMaxHeadRoom() *resources.Resource {
var parentHeadRoom *resources.Resource
if sq.parent != nil {
parentHeadRoom = sq.parent.getMaxHeadRoom()
} else {
return nil
}
return sq.internalHeadRoom(parentHeadRoom)
}
```
And then in the `internalHeadRoom` the real calculation:
```
func (sq *SchedulingQueue) internalHeadRoom(parentHeadRoom
*resources.Resource) *resources.Resource {
sq.RLock()
defer sq.RUnlock()
headRoom := sq.QueueInfo.GetMaxResource()
// if we have no max set headroom is always the same as the parent
if headRoom == nil {
return parentHeadRoom
}
// calculate unused
headRoom.SubFrom(sq.allocating)
headRoom.SubFrom(sq.QueueInfo.GetAllocatedResource())
// check the minimum of the two: parentHeadRoom is nil for root
if parentHeadRoom == nil {
return headRoom
}
return resources.ComponentWiseMin(headRoom, parentHeadRoom)
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]