Unverified Commit bf7c7581 authored by Klaus Ma's avatar Klaus Ma Committed by GitHub
Browse files

Merge pull request #115 from k82cn/vk_114

Updated kube-batch to vk-kube-batch.
parents 95a01804 844786fd
Showing with 64 additions and 6 deletions
+64 -6
......@@ -203,8 +203,8 @@
version = "1.1.4"
[[projects]]
branch = "volcano-master"
digest = "1:52294fbd6648d468a03845d1d908a8d6e5a86d5cd9fe7f32236d8275721a92df"
branch = "master"
digest = "1:373e831b25d35980629d8042cf8941f1455cee70e846e2c91064ecb074ce3826"
name = "github.com/kubernetes-sigs/kube-batch"
packages = [
"cmd/kube-batch/app",
......@@ -223,6 +223,7 @@
"pkg/scheduler/actions",
"pkg/scheduler/actions/allocate",
"pkg/scheduler/actions/backfill",
"pkg/scheduler/actions/enqueue",
"pkg/scheduler/actions/preempt",
"pkg/scheduler/actions/reclaim",
"pkg/scheduler/api",
......@@ -244,7 +245,7 @@
"pkg/version",
]
pruneopts = "UT"
revision = "5e9977d68a13938fbb6d7dda564da0dca1b1c98c"
revision = "2e229b9ef61ca616735b667beb77a01fac2bb5f1"
source = "https://github.com/volcano-sh/kube-batch"
[[projects]]
......
......@@ -38,7 +38,7 @@ required = [
[[constraint]]
name = "github.com/kubernetes-sigs/kube-batch"
branch = "volcano-master"
branch = "master"
source = "https://github.com/volcano-sh/kube-batch"
[[constraint]]
......
......@@ -36,6 +36,10 @@ const (
// PodGroupUnknown means part of `spec.minMember` pods are running but the other part can not
// be scheduled, e.g. not enough resource; scheduler will wait for related controller to recover it.
PodGroupUnknown PodGroupPhase = "Unknown"
// PodGroupInqueue means controllers can start to create pods,
// is a new state between PodGroupPending and PodGroupRunning
PodGroupInqueue PodGroupPhase = "Inqueue"
)
type PodGroupConditionType string
......@@ -123,6 +127,11 @@ type PodGroupSpec struct {
// default.
// +optional
PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,3,opt,name=priorityClassName"`
// MinResources defines the minimal resource of members/tasks to run the pod group;
// if there's not enough resources to start all tasks, the scheduler
// will not start anyone.
MinResources *v1.ResourceList `json:"minResources,omitempty" protobuf:"bytes,4,opt,name=minResources"`
}
// PodGroupStatus represents the current state of a pod group.
......
......@@ -21,6 +21,8 @@ limitations under the License.
package v1alpha1
import (
v1 "k8s.io/api/core/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
runtime "k8s.io/apimachinery/pkg/runtime"
)
......@@ -29,7 +31,7 @@ func (in *PodGroup) DeepCopyInto(out *PodGroup) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
......@@ -105,6 +107,17 @@ func (in *PodGroupList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodGroupSpec) DeepCopyInto(out *PodGroupSpec) {
*out = *in
if in.MinResources != nil {
in, out := &in.MinResources, &out.MinResources
*out = new(v1.ResourceList)
if **in != nil {
in, out := *in, *out
*out = make(map[v1.ResourceName]resource.Quantity, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
}
return
}
......
......@@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/util"
......@@ -48,6 +49,10 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
jobsMap := map[api.QueueID]*util.PriorityQueue{}
for _, job := range ssn.Jobs {
if job.PodGroup.Status.Phase == v1alpha1.PodGroupPending {
continue
}
if queue, found := ssn.Queues[job.Queue]; found {
queues.Push(queue)
} else {
......
......@@ -19,6 +19,7 @@ package backfill
import (
"github.com/golang/glog"
"github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"
)
......@@ -43,6 +44,10 @@ func (alloc *backfillAction) Execute(ssn *framework.Session) {
// TODO (k82cn): When backfill, it's also need to balance between Queues.
for _, job := range ssn.Jobs {
if job.PodGroup.Status.Phase == v1alpha1.PodGroupPending {
continue
}
for _, task := range job.TaskStatusIndex[api.Pending] {
if task.InitResreq.IsEmpty() {
// As task did not request resources, so it only need to meet predicates.
......
......@@ -21,6 +21,7 @@ import (
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/allocate"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/backfill"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/enqueue"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/preempt"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/reclaim"
)
......@@ -30,4 +31,5 @@ func init() {
framework.RegisterAction(allocate.New())
framework.RegisterAction(backfill.New())
framework.RegisterAction(preempt.New())
framework.RegisterAction(enqueue.New())
}
......@@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/metrics"
......@@ -52,6 +53,10 @@ func (alloc *preemptAction) Execute(ssn *framework.Session) {
queues := map[api.QueueID]*api.QueueInfo{}
for _, job := range ssn.Jobs {
if job.PodGroup.Status.Phase == v1alpha1.PodGroupPending {
continue
}
if queue, found := ssn.Queues[job.Queue]; !found {
continue
} else if _, existed := queues[queue.UID]; !existed {
......
......@@ -19,6 +19,7 @@ package reclaim
import (
"github.com/golang/glog"
"github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/util"
......@@ -53,6 +54,10 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) {
var underRequest []*api.JobInfo
for _, job := range ssn.Jobs {
if job.PodGroup.Status.Phase == v1alpha1.PodGroupPending {
continue
}
if queue, found := ssn.Queues[job.Queue]; !found {
glog.Errorf("Failed to find Queue <%s> for Job <%s/%s>",
job.Queue, job.Namespace, job.Name)
......
......@@ -20,6 +20,8 @@ import (
"fmt"
"math"
"k8s.io/apimachinery/pkg/api/resource"
v1 "k8s.io/api/core/v1"
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
)
......@@ -324,3 +326,14 @@ func (r *Resource) SetScalar(name v1.ResourceName, quantity float64) {
}
r.ScalarResources[name] = quantity
}
func (r *Resource) Convert2K8sResource() *v1.ResourceList {
list := v1.ResourceList{
v1.ResourceCPU: *resource.NewMilliQuantity(int64(r.MilliCPU), resource.DecimalSI),
v1.ResourceMemory: *resource.NewQuantity(int64(r.Memory), resource.BinarySI),
}
for name, value := range r.ScalarResources {
list[name] = *resource.NewQuantity(int64(value), resource.BinarySI)
}
return &list
}
......@@ -171,7 +171,7 @@ func jobStatus(ssn *Session, jobInfo *api.JobInfo) v1alpha1.PodGroupStatus {
// If there're enough allocated resource, it's running
if int32(allocated) > jobInfo.PodGroup.Spec.MinMember {
status.Phase = v1alpha1.PodGroupRunning
} else {
} else if jobInfo.PodGroup.Status.Phase != v1alpha1.PodGroupInqueue {
status.Phase = v1alpha1.PodGroupPending
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment