Skip to content

Commit 453738c

Browse files
author
Klaus Ma
authored
Merge pull request volcano-sh#50 from volcano-sh/feature/support-plugins
2 parents 5bec9fb + dcfb24b commit 453738c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+15694
-64
lines changed

Gopkg.lock

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+5
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,15 @@ required = [
8888
name = "k8s.io/code-generator"
8989
version = "kubernetes-1.13.2"
9090

91+
[[constraint]]
92+
name = "golang.org/x/crypto"
93+
branch = "release-branch.go1.12"
94+
9195
[prune]
9296
go-tests = true
9397
unused-packages = true
9498

9599
[[prune.project]]
96100
name = "k8s.io/code-generator"
97101
unused-packages = false
102+

example/job.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spec:
2020
storage: 1Gi
2121
tasks:
2222
- replicas: 6
23+
name: "default-nginx"
2324
template:
2425
metadata:
2526
name: web

example/kube-batch-conf.yaml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
actions: "reclaim, allocate, backfill, preempt"
22
tiers:
3-
- plugins:
4-
- name: priority
5-
- name: gang
6-
- plugins:
7-
- name: drf
8-
- name: predicates
9-
- name: proportion
3+
- plugins:
4+
- name: priority
5+
- name: gang
6+
- name: conformance
7+
- plugins:
8+
- name: drf
9+
- name: predicates
10+
- name: proportion
11+
- name: nodeorder

hack/.golint_failures

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ volcano.sh/volcano/pkg/cli/job
1010
volcano.sh/volcano/pkg/controllers/job
1111
volcano.sh/volcano/pkg/controllers/job/apis
1212
volcano.sh/volcano/pkg/controllers/job/cache
13+
volcano.sh/volcano/pkg/controllers/job/helpers
14+
volcano.sh/volcano/pkg/controllers/job/plugins
15+
volcano.sh/volcano/pkg/controllers/job/plugins/env
16+
volcano.sh/volcano/pkg/controllers/job/plugins/interface
17+
volcano.sh/volcano/pkg/controllers/job/plugins/ssh
1318
volcano.sh/volcano/pkg/controllers/job/state
1419
volcano.sh/volcano/pkg/scheduler/actions/allocate
1520
volcano.sh/volcano/pkg/scheduler/actions/backfill

installer/chart/volcano/templates/admission-config.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ metadata:
66
"helm.sh/hook": pre-install,pre-upgrade,post-delete
77
webhooks:
88
- clientConfig:
9-
caBundle: ""
109
service:
1110
name: {{ .Release.Name }}-admission-service
1211
namespace: {{ .Release.Namespace }}
@@ -33,7 +32,6 @@ metadata:
3332
"helm.sh/hook": pre-install,pre-upgrade,post-delete
3433
webhooks:
3534
- clientConfig:
36-
caBundle: ""
3735
service:
3836
name: {{ .Release.Name }}-admission-service
3937
namespace: {{ .Release.Namespace }}

installer/chart/volcano/templates/admission.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ spec:
5757
admission: "true"
5858
spec:
5959
serviceAccount: {{ .Release.Name }}-admission
60+
{{ if .Values.basic.image_pull_secret }}
61+
imagePullSecrets:
62+
- name: {{ .Values.basic.image_pull_secret }}
63+
{{ end }}
6064
containers:
6165
- args:
6266
- --tls-cert-file=/admission.local.config/certificates/tls.crt

installer/chart/volcano/templates/controllers.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ rules:
3636
resources: ["persistentvolumeclaims"]
3737
verbs: ["get", "list", "watch", "create"]
3838
- apiGroups: [""]
39-
resources: ["services"]
39+
resources: ["services", "configmaps"]
4040
verbs: ["get", "list", "watch", "create", "delete"]
4141
- apiGroups: ["scheduling.incubator.k8s.io"]
4242
resources: ["podgroups"]
@@ -74,6 +74,10 @@ spec:
7474
vk-controllers: test
7575
spec:
7676
serviceAccount: {{ .Release.Name }}-controllers
77+
{{ if .Values.basic.image_pull_secret }}
78+
imagePullSecrets:
79+
- name: {{ .Values.basic.image_pull_secret }}
80+
{{ end }}
7781
containers:
7882
- name: {{ .Release.Name }}-controllers
7983
image: {{.Values.basic.controller_image_name}}:{{.Values.basic.image_tag_version}}

installer/chart/volcano/values.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ basic:
33
controller_image_name: "volcano-controllers"
44
scheduler_image_name: "volcano-scheduler"
55
admission_image_name: "volcano-admission"
6-
admission_secret_name: "volcano-admission-secret"
6+
admission_secret_name: "volcano-admission-secret"
7+
image_pull_secret: ""

pkg/admission/admit_job.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"reflect"
2222
"strings"
23+
"volcano.sh/volcano/pkg/controllers/job/plugins"
2324

2425
"github.com/golang/glog"
2526

@@ -43,7 +44,7 @@ func AdmitJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
4344

4445
switch ar.Request.Operation {
4546
case v1beta1.Create:
46-
msg = validateJob(job, &reviewResponse)
47+
msg = validateJobSpec(job.Spec, &reviewResponse)
4748
break
4849
case v1beta1.Update:
4950
oldJob, err := DecodeJob(ar.Request.OldObject, ar.Request.Resource)
@@ -63,18 +64,18 @@ func AdmitJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
6364
return &reviewResponse
6465
}
6566

66-
func validateJob(job v1alpha1.Job, reviewResponse *v1beta1.AdmissionResponse) string {
67+
func validateJobSpec(jobSpec v1alpha1.JobSpec, reviewResponse *v1beta1.AdmissionResponse) string {
6768

6869
var msg string
6970
taskNames := map[string]string{}
7071
var totalReplicas int32
7172

72-
if len(job.Spec.Tasks) == 0 {
73+
if len(jobSpec.Tasks) == 0 {
7374
reviewResponse.Allowed = false
7475
return fmt.Sprintf("No task specified in job spec")
7576
}
7677

77-
for _, task := range job.Spec.Tasks {
78+
for _, task := range jobSpec.Tasks {
7879
if task.Replicas == 0 {
7980
msg = msg + fmt.Sprintf(" 'replicas' is set '0' in task: %s;", task.Name)
8081
}
@@ -96,15 +97,24 @@ func validateJob(job v1alpha1.Job, reviewResponse *v1beta1.AdmissionResponse) st
9697
}
9798
}
9899

99-
if totalReplicas < job.Spec.MinAvailable {
100+
if totalReplicas < jobSpec.MinAvailable {
100101
msg = msg + " 'minAvailable' should not be greater than total replicas in tasks;"
101102
}
102103

103104
//duplicate job event policies
104-
if duplicateInfo, ok := CheckPolicyDuplicate(job.Spec.Policies); ok {
105+
if duplicateInfo, ok := CheckPolicyDuplicate(jobSpec.Policies); ok {
105106
msg = msg + fmt.Sprintf(" duplicated job event policies: %s;", duplicateInfo)
106107
}
107108

109+
//invalid job plugins
110+
if len(jobSpec.Plugins) != 0 {
111+
for name := range jobSpec.Plugins {
112+
if _, found := plugins.GetPluginBuilder(name); !found {
113+
msg = msg + fmt.Sprintf(" unable to find job plugin: %s", name)
114+
}
115+
}
116+
}
117+
108118
if msg != "" {
109119
reviewResponse.Allowed = false
110120
}

pkg/apis/batch/v1alpha1/job.go

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ type JobSpec struct {
6363

6464
//Specifies the queue that will be used in the scheduler, "default" queue is used this leaves empty.
6565
Queue string `json:"queue,omitempty" protobuf:"bytes,7,opt,name=queue"`
66+
67+
// Specifies the plugin of job
68+
// Key is plugin name, value is the arguments of the plugin
69+
// +optional
70+
Plugins map[string][]string `json:"plugins,omitempty" protobuf:"bytes,7,opt,name=plugins"`
6671
}
6772

6873
// VolumeSpec defines the specification of Volume, e.g. PVC
@@ -79,6 +84,7 @@ type JobEvent string
7984

8085
const (
8186
CommandIssued JobEvent = "CommandIssued"
87+
PluginError JobEvent = "PluginError"
8288
)
8389

8490
// Event represent the phase of Job, e.g. pod-failed.
@@ -232,6 +238,8 @@ type JobStatus struct {
232238
Terminating int32 `json:"terminating,omitempty" protobuf:"bytes,7,opt,name=terminating"`
233239
//Current version of job
234240
Version int32 `json:"version,omitempty" protobuf:"bytes,8,opt,name=version"`
241+
// The resources that controlled by this job, e.g. Service, ConfigMap
242+
ControlledResources map[string]string
235243
}
236244

237245
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/apis/batch/v1alpha1/zz_generated.deepcopy.go

+23-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)