Skip to content

Commit

Permalink
Merge branch 'github_190422' into 'master'
Browse files Browse the repository at this point in the history
[Issue volcano-sh#63] sync code from github / 190422

## related pr


* Add UT cases for Preempt Action | kubernetes-retired/kube-batch#751
>!! need fix bug on allocate/preempt UT
>errors about enqueue


* support extended resource for kube-batch | kubernetes-retired/kube-batch#795
>modity Convert2K8sResource in resources_info.go


* Fix verify | kubernetes-retired/kube-batch#792
>modify manually


* Remove reclaim and preempt in deployment | kubernetes-retired/kube-batch#772
>add enqueue in kube-conf-ci.conf


* Add CheckNodeDiskPressure,CheckNodePIDPressure,CheckNodeMemoryPressur… | kubernetes-retired/kube-batch#800
>!! need fix bug on reclaim UT
>errors about enqueue


* Add UT Cases for Reclaim Action | kubernetes-retired/kube-batch#801

* Prevent memory leak | kubernetes-retired/kube-batch#809

* Migrate duplicated code in nodeorder and predicate plugin | kubernetes-retired/kube-batch#816


## not applied pr

* restore kube-batch | https://github.com/kubernetes-sigs/kube-batch/pull/791/files

* Add Volcano Installation Tutorial Link | https://github.com/kubernetes-sigs/kube-batch/pull/796/files

* Add document for MPI example | https://github.com/kubernetes-sigs/kube-batch/pull/793/files

* Update tutorial.md | https://github.com/kubernetes-sigs/kube-batch/pull/808/files

* Add kubemark support | https://github.com/kubernetes-sigs/kube-batch/pull/810/files

Issues info:
Issue ID: 63
Title: sync code from github / 190422
Issue url: CBU-PaaS/Community/volcano/volcano#63


See merge request CBU-PaaS/Community/volcano/volcano!106
  • Loading branch information
mada 00483107 committed Apr 22, 2019
2 parents a858837 + ef2bc6b commit f231e93
Show file tree
Hide file tree
Showing 20 changed files with 1,340 additions and 319 deletions.
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ images: rel_bins

docker: images

generate-deepcopy: init
go build -o ${BIN_DIR}/deepcopy-gen ./cmd/deepcopy-gen/
${BIN_DIR}/deepcopy-gen -i ./pkg/apis/scheduling/v1alpha1/ -O zz_generated.deepcopy --go-header-file hack/boilerplate/boilerplate.generatego.txt
${BIN_DIR}/deepcopy-gen -i ./pkg/apis/batch/v1alpha1/ -O zz_generated.deepcopy --go-header-file hack/boilerplate/boilerplate.generatego.txt
${BIN_DIR}/deepcopy-gen -i ./pkg/apis/bus/v1alpha1/ -O zz_generated.deepcopy --go-header-file hack/boilerplate/boilerplate.generatego.txt

generate-code:
./hack/update-gencode.sh

Expand Down
11 changes: 11 additions & 0 deletions deployment/volcano/config/kube-batch-ci.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
actions: "enqueue, reclaim, allocate, backfill, preempt"
tiers:
- plugins:
- name: priority
- name: gang
- name: conformance
- plugins:
- name: drf
- name: predicates
- name: proportion
- name: nodeorder
2 changes: 1 addition & 1 deletion deployment/volcano/config/kube-batch.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions: "enqueue, reclaim, allocate, backfill, preempt"
actions: "enqueue, allocate, backfill"
tiers:
- plugins:
- name: priority
Expand Down
2 changes: 1 addition & 1 deletion deployment/volcano/templates/scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
image: {{.Values.basic.scheduler_image_name}}:{{.Values.basic.image_tag_version}}
args:
- --alsologtostderr
- --scheduler-conf=/volcano.scheduler/kube-batch.conf
- --scheduler-conf={{.Values.basic.scheduler_conf_file}}
- -v=3
- 2>&1
imagePullPolicy: "IfNotPresent"
Expand Down
1 change: 1 addition & 0 deletions deployment/volcano/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ basic:
admission_image_name: "kubesigs/vk-admission"
admission_secret_name: "volcano-admission-secret"
image_pull_secret: ""
scheduler_conf_file: "/volcano.scheduler/kube-batch.conf"
2 changes: 1 addition & 1 deletion hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function install-volcano {
helm gen-admission-secret --service integration-admission-service --namespace kube-system

echo "Install volcano chart"
helm install deployment/volcano --namespace kube-system --name integration --kubeconfig ${KUBECONFIG} --set basic.image_tag_version=${TAG}
helm install deployment/volcano --namespace kube-system --name integration --kubeconfig ${KUBECONFIG} --set basic.image_tag_version=${TAG} --set basic.scheduler_conf_file=/volcano.scheduler/kube-batch-ci.conf

echo "Load required image"
kind load docker-image ${TEST_BUSYBOX_IMAGE} ${CLUSTER_CONTEXT}
Expand Down
136 changes: 17 additions & 119 deletions pkg/scheduler/actions/allocate/allocate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ limitations under the License.
package allocate

import (
"fmt"

"reflect"
"sync"
"testing"
"time"

"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"

kbv1 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
Expand All @@ -37,106 +32,9 @@ import (
"volcano.sh/volcano/pkg/scheduler/framework"
"volcano.sh/volcano/pkg/scheduler/plugins/drf"
"volcano.sh/volcano/pkg/scheduler/plugins/proportion"
"volcano.sh/volcano/pkg/scheduler/util"
)

func buildResourceList(cpu string, memory string) v1.ResourceList {
return v1.ResourceList{
v1.ResourceCPU: resource.MustParse(cpu),
v1.ResourceMemory: resource.MustParse(memory),
api.GPUResourceName: resource.MustParse("0"),
}
}

func buildResourceListWithGPU(cpu string, memory string, GPU string) v1.ResourceList {
return v1.ResourceList{
v1.ResourceCPU: resource.MustParse(cpu),
v1.ResourceMemory: resource.MustParse(memory),
api.GPUResourceName: resource.MustParse(GPU),
}
}

func buildNode(name string, alloc v1.ResourceList, labels map[string]string) *v1.Node {
return &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Status: v1.NodeStatus{
Capacity: alloc,
Allocatable: alloc,
},
}
}

func buildPod(ns, n, nn string, p v1.PodPhase, req v1.ResourceList, groupName string, labels map[string]string, selector map[string]string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: types.UID(fmt.Sprintf("%v-%v", ns, n)),
Name: n,
Namespace: ns,
Labels: labels,
Annotations: map[string]string{
kbv1.GroupNameAnnotationKey: groupName,
},
},
Status: v1.PodStatus{
Phase: p,
},
Spec: v1.PodSpec{
NodeName: nn,
NodeSelector: selector,
Containers: []v1.Container{
{
Resources: v1.ResourceRequirements{
Requests: req,
},
},
},
},
}
}

type fakeBinder struct {
sync.Mutex
binds map[string]string
c chan string
}

func (fb *fakeBinder) Bind(p *v1.Pod, hostname string) error {
fb.Lock()
defer fb.Unlock()

key := fmt.Sprintf("%v/%v", p.Namespace, p.Name)
fb.binds[key] = hostname

fb.c <- key

return nil
}

type fakeStatusUpdater struct {
}

func (ftsu *fakeStatusUpdater) UpdatePodCondition(pod *v1.Pod, podCondition *v1.PodCondition) (*v1.Pod, error) {
// do nothing here
return nil, nil
}

func (ftsu *fakeStatusUpdater) UpdatePodGroup(pg *kbv1.PodGroup) (*kbv1.PodGroup, error) {
// do nothing here
return nil, nil
}

type fakeVolumeBinder struct {
}

func (fvb *fakeVolumeBinder) AllocateVolumes(task *api.TaskInfo, hostname string) error {
return nil
}
func (fvb *fakeVolumeBinder) BindVolumes(task *api.TaskInfo) error {
return nil
}

func TestAllocate(t *testing.T) {
framework.RegisterPluginBuilder("drf", drf.New)
framework.RegisterPluginBuilder("proportion", proportion.New)
Expand Down Expand Up @@ -164,11 +62,11 @@ func TestAllocate(t *testing.T) {
},
},
pods: []*v1.Pod{
buildPod("c1", "p1", "", v1.PodPending, buildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
buildPod("c1", "p2", "", v1.PodPending, buildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
util.BuildPod("c1", "p1", "", v1.PodPending, util.BuildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
util.BuildPod("c1", "p2", "", v1.PodPending, util.BuildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
},
nodes: []*v1.Node{
buildNode("n1", buildResourceList("2", "4Gi"), make(map[string]string)),
util.BuildNode("n1", util.BuildResourceList("2", "4Gi"), make(map[string]string)),
},
queues: []*kbv1.Queue{
{
Expand Down Expand Up @@ -210,16 +108,16 @@ func TestAllocate(t *testing.T) {

pods: []*v1.Pod{
// pending pod with owner1, under c1
buildPod("c1", "p1", "", v1.PodPending, buildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
util.BuildPod("c1", "p1", "", v1.PodPending, util.BuildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
// pending pod with owner1, under c1
buildPod("c1", "p2", "", v1.PodPending, buildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
util.BuildPod("c1", "p2", "", v1.PodPending, util.BuildResourceList("1", "1G"), "pg1", make(map[string]string), make(map[string]string)),
// pending pod with owner2, under c2
buildPod("c2", "p1", "", v1.PodPending, buildResourceList("1", "1G"), "pg2", make(map[string]string), make(map[string]string)),
util.BuildPod("c2", "p1", "", v1.PodPending, util.BuildResourceList("1", "1G"), "pg2", make(map[string]string), make(map[string]string)),
// pending pod with owner, under c2
buildPod("c2", "p2", "", v1.PodPending, buildResourceList("1", "1G"), "pg2", make(map[string]string), make(map[string]string)),
util.BuildPod("c2", "p2", "", v1.PodPending, util.BuildResourceList("1", "1G"), "pg2", make(map[string]string), make(map[string]string)),
},
nodes: []*v1.Node{
buildNode("n1", buildResourceList("2", "4G"), make(map[string]string)),
util.BuildNode("n1", util.BuildResourceList("2", "4G"), make(map[string]string)),
},
queues: []*kbv1.Queue{
{
Expand Down Expand Up @@ -249,17 +147,17 @@ func TestAllocate(t *testing.T) {
allocate := New()

for i, test := range tests {
binder := &fakeBinder{
binds: map[string]string{},
c: make(chan string),
binder := &util.FakeBinder{
Binds: map[string]string{},
Channel: make(chan string),
}
schedulerCache := &cache.SchedulerCache{
Nodes: make(map[string]*api.NodeInfo),
Jobs: make(map[api.JobID]*api.JobInfo),
Queues: make(map[api.QueueID]*api.QueueInfo),
Binder: binder,
StatusUpdater: &fakeStatusUpdater{},
VolumeBinder: &fakeVolumeBinder{},
StatusUpdater: &util.FakeStatusUpdater{},
VolumeBinder: &util.FakeVolumeBinder{},

Recorder: record.NewFakeRecorder(100),
}
Expand Down Expand Up @@ -301,14 +199,14 @@ func TestAllocate(t *testing.T) {

for i := 0; i < len(test.expected); i++ {
select {
case <-binder.c:
case <-binder.Channel:
case <-time.After(3 * time.Second):
t.Errorf("Failed to get binding request.")
}
}

if !reflect.DeepEqual(test.expected, binder.binds) {
t.Errorf("case %d (%s): expected: %v, got %v ", i, test.name, test.expected, binder.binds)
if !reflect.DeepEqual(test.expected, binder.Binds) {
t.Errorf("case %d (%s): expected: %v, got %v ", i, test.name, test.expected, binder.Binds)
}
}
}
Loading

0 comments on commit f231e93

Please sign in to comment.