Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug: capability validation failed when some running jobs finished or deleted #959

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/scheduler/actions/enqueue/enqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func (enqueue *Action) Execute(ssn *framework.Session) {

queues := util.NewPriorityQueue(ssn.QueueOrderFn)
queueMap := map[api.QueueID]*api.QueueInfo{}

jobsMap := map[api.QueueID]*util.PriorityQueue{}

for _, job := range ssn.Jobs {
Expand All @@ -69,6 +68,7 @@ func (enqueue *Action) Execute(ssn *framework.Session) {

queueMap[queue.UID] = queue
queues.Push(queue)
ssn.InqueueJobResource[queue.UID] = api.EmptyResource()
}

if job.PodGroup.Status.Phase == scheduling.PodGroupPending {
Expand All @@ -78,6 +78,11 @@ func (enqueue *Action) Execute(ssn *framework.Session) {
klog.V(3).Infof("Added Job <%s/%s> into Queue <%s>", job.Namespace, job.Name, job.Queue)
jobsMap[job.Queue].Push(job)
}

if job.PodGroup.Status.Phase == scheduling.PodGroupInqueue {
klog.V(3).Infof("Added Job <%s/%s> into InqueueResource", job.Namespace, job.Name)
ssn.InqueueJobResource[job.Queue].Add(api.NewResource(*job.PodGroup.Spec.MinResources))
}
}

klog.V(3).Infof("Try to enqueue PodGroup to %d Queues", len(jobsMap))
Expand Down Expand Up @@ -124,6 +129,7 @@ func (enqueue *Action) Execute(ssn *framework.Session) {
if inqueue {
job.PodGroup.Status.Phase = scheduling.PodGroupInqueue
ssn.Jobs[job.UID] = job
ssn.InqueueJobResource[job.Queue].Add(api.NewResource(*job.PodGroup.Spec.MinResources))
}

// Added Queue back until no job in Queue.
Expand Down
17 changes: 10 additions & 7 deletions pkg/scheduler/framework/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ type Session struct {
// This should not be mutated after initiated
podGroupStatus map[api.JobID]scheduling.PodGroupStatus

Jobs map[api.JobID]*api.JobInfo
Nodes map[string]*api.NodeInfo
Queues map[api.QueueID]*api.QueueInfo
NamespaceInfo map[api.NamespaceName]*api.NamespaceInfo
Jobs map[api.JobID]*api.JobInfo
Nodes map[string]*api.NodeInfo
Queues map[api.QueueID]*api.QueueInfo
NamespaceInfo map[api.NamespaceName]*api.NamespaceInfo
InqueueJobResource map[api.QueueID]*api.Resource

Tiers []conf.Tier
Configurations []conf.Configuration
Expand Down Expand Up @@ -81,9 +82,10 @@ func openSession(cache cache.Cache) *Session {

podGroupStatus: map[api.JobID]scheduling.PodGroupStatus{},

Jobs: map[api.JobID]*api.JobInfo{},
Nodes: map[string]*api.NodeInfo{},
Queues: map[api.QueueID]*api.QueueInfo{},
Jobs: map[api.JobID]*api.JobInfo{},
Nodes: map[string]*api.NodeInfo{},
Queues: map[api.QueueID]*api.QueueInfo{},
InqueueJobResource: map[api.QueueID]*api.Resource{},

plugins: map[string]Plugin{},
jobOrderFns: map[string]api.CompareFn{},
Expand Down Expand Up @@ -155,6 +157,7 @@ func closeSession(ssn *Session) {
ssn.jobOrderFns = nil
ssn.namespaceOrderFns = nil
ssn.queueOrderFns = nil
ssn.InqueueJobResource = nil

klog.V(3).Infof("Close Session %v", ssn.UID)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/scheduler/plugins/proportion/proportion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package proportion

import (
"k8s.io/klog"

"volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/api/helpers"
"volcano.sh/volcano/pkg/scheduler/framework"
Expand Down Expand Up @@ -243,7 +242,7 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {

minReq := api.NewResource(*job.PodGroup.Spec.MinResources)
// The queue resource quota limit has not reached
return minReq.Add(attr.allocated).LessEqual(api.NewResource(queue.Queue.Spec.Capability))
return minReq.Add(attr.allocated).Add(ssn.InqueueJobResource[job.Queue]).LessEqual(api.NewResource(queue.Queue.Spec.Capability))
})

// Register event handlers.
Expand Down