Skip to content

Commit

Permalink
Merge pull request #364 from hzxuzhonghu/v1alpha2
Browse files Browse the repository at this point in the history
migrate queue/podgroup to v1alpha2
  • Loading branch information
volcano-sh-bot authored Jul 26, 2019
2 parents 9d675f1 + 60f7ce6 commit 71ad4ce
Show file tree
Hide file tree
Showing 36 changed files with 326 additions and 322 deletions.
3 changes: 0 additions & 3 deletions hack/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
BINARY_FOLDER=${VK_ROOT}/${BIN_DIR}/${REL_OSARCH}
RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR}
RELEASE_BINARY=${RELEASE_FOLDER}/bin
QUEUE_FILE=${VK_ROOT}/installer/helm/chart/volcano/templates/default-queue.yaml
README_FILE=${VK_ROOT}/installer/README.md
HELM_FOLDER=${VK_ROOT}/installer/helm
VOLCANO_IMAGE_TAG=${TAG:-"latest"}
Expand All @@ -49,8 +48,6 @@ cp -r ${BINARY_FOLDER} ${RELEASE_BINARY}

cp ${README_FILE} ${RELEASE_FOLDER}

cp ${QUEUE_FILE} ${RELEASE_FOLDER}

cp -r ${HELM_FOLDER} ${RELEASE_FOLDER}

if [[ -f ${LICENSE_FILE} ]];then
Expand Down
4 changes: 0 additions & 4 deletions installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ replicaset.apps/volcano-admission-56f5465597 1 1 1 36s
replicaset.apps/volcano-controllers-687948d9c8 1 1 1 36s
replicaset.apps/volcano-scheduler-94998fc64 1 1 1 36s
```
Volcano scheduler utilize `queues.scheduling.incubator.k8s.io` to share resource, therefore default queue is required before usage.
```$xslt
kubectl apply -f default-queue.yaml
```

## Installing volcano via helm charts

Expand Down
2 changes: 1 addition & 1 deletion installer/helm/chart/volcano/templates/admission.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "patch"]
- apiGroups: ["scheduling.incubator.k8s.io"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["queues"]
verbs: ["get", "list"]
- apiGroups: [""]
Expand Down
2 changes: 1 addition & 1 deletion installer/helm/chart/volcano/templates/controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
- apiGroups: ["scheduling.incubator.k8s.io"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["podgroups", "queues", "queues/status"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
- apiGroups: ["scheduling.k8s.io"]
Expand Down
9 changes: 3 additions & 6 deletions installer/helm/chart/volcano/templates/scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["list", "watch"]
- apiGroups: ["scheduling.incubator.k8s.io"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["podgroups"]
verbs: ["list", "watch", "update"]
- apiGroups: [""]
Expand All @@ -57,16 +57,13 @@ rules:
- apiGroups: ["policy"]
resources: ["poddisruptionbudgets"]
verbs: ["list", "watch"]
- apiGroups: ["scheduling.incubator.k8s.io"]
resources: ["queues"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["scheduling.k8s.io"]
resources: ["priorityclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["scheduling.sigs.dev"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["queues"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["scheduling.sigs.dev"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["podgroups"]
verbs: ["list", "watch", "update"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ spec:
names:
kind: PodGroup
plural: podgroups
shortNames:
- pg
- podgroup-v1alpha2
scope: Namespaced
validation:
openAPIV3Schema:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ spec:
names:
kind: Queue
plural: queues
shortNames:
- q
- queue-v1alpha2
scope: Cluster
validation:
openAPIV3Schema:
Expand Down Expand Up @@ -37,3 +40,5 @@ spec:
type: object
type: object
version: v1alpha2
subresources:
status: {}
21 changes: 13 additions & 8 deletions installer/volcano-development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["list", "watch"]
- apiGroups: ["scheduling.incubator.k8s.io"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["podgroups"]
verbs: ["list", "watch", "update"]
- apiGroups: [""]
Expand All @@ -87,16 +87,13 @@ rules:
- apiGroups: ["policy"]
resources: ["poddisruptionbudgets"]
verbs: ["list", "watch"]
- apiGroups: ["scheduling.incubator.k8s.io"]
resources: ["queues"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["scheduling.k8s.io"]
resources: ["priorityclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["scheduling.sigs.dev"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["queues"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["scheduling.sigs.dev"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["podgroups"]
verbs: ["list", "watch", "update"]

Expand Down Expand Up @@ -182,7 +179,7 @@ rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "patch"]
- apiGroups: ["scheduling.incubator.k8s.io"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["queues"]
verbs: ["get", "list"]
- apiGroups: [""]
Expand Down Expand Up @@ -331,7 +328,7 @@ rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
- apiGroups: ["scheduling.incubator.k8s.io"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.sigs.dev"]
resources: ["podgroups", "queues", "queues/status"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
- apiGroups: ["scheduling.k8s.io"]
Expand Down Expand Up @@ -724,6 +721,9 @@ spec:
names:
kind: PodGroup
plural: podgroups
shortNames:
- pg
- podgroup-v1alpha2
scope: Namespaced
validation:
openAPIV3Schema:
Expand Down Expand Up @@ -770,6 +770,9 @@ spec:
names:
kind: Queue
plural: queues
shortNames:
- q
- queue-v1alpha2
scope: Cluster
validation:
openAPIV3Schema:
Expand Down Expand Up @@ -800,4 +803,6 @@ spec:
type: object
type: object
version: v1alpha2
subresources:
status: {}

7 changes: 5 additions & 2 deletions pkg/admission/admit_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ func validateJob(job v1alpha1.Job, reviewResponse *v1beta1.AdmissionResponse) st
}

// Check whether Queue already present or not
if _, err := KubeBatchClientSet.SchedulingV1alpha1().Queues().Get(job.Spec.Queue, metav1.GetOptions{}); err != nil {
msg = msg + fmt.Sprintf("Job not created with error: %v", err)
if _, err := KubeBatchClientSet.SchedulingV1alpha2().Queues().Get(job.Spec.Queue, metav1.GetOptions{}); err != nil {
// TODO: deprecate v1alpha1
if _, err := KubeBatchClientSet.SchedulingV1alpha1().Queues().Get(job.Spec.Queue, metav1.GetOptions{}); err != nil {
msg = msg + fmt.Sprintf(" unable to find job queue: %v", err)
}
}

if msg != "" {
Expand Down
80 changes: 39 additions & 41 deletions pkg/admission/admit_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import (
"strings"
"testing"

kubebatchclient "volcano.sh/volcano/pkg/client/clientset/versioned/fake"

"k8s.io/api/admission/v1beta1"
v1 "k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

v1alpha1 "volcano.sh/volcano/pkg/apis/batch/v1alpha1"
kbv1aplha1 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
"volcano.sh/volcano/pkg/apis/batch/v1alpha1"
schedulingv1aplha2 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha2"
fakeclient "volcano.sh/volcano/pkg/client/clientset/versioned/fake"
)

func TestValidateExecution(t *testing.T) {
Expand Down Expand Up @@ -942,49 +941,48 @@ func TestValidateExecution(t *testing.T) {
},
},
reviewResponse: v1beta1.AdmissionResponse{Allowed: true},
ret: "Job not created with error: ",
ret: "unable to find job queue",
ExpectErr: true,
},
}

for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
defaultqueue := schedulingv1aplha2.Queue{
ObjectMeta: metav1.ObjectMeta{
Name: "default",
},
Spec: schedulingv1aplha2.QueueSpec{
Weight: 1,
},
}
// create fake volcano clientset
KubeBatchClientSet = fakeclient.NewSimpleClientset()

defaultqueue := kbv1aplha1.Queue{
ObjectMeta: metav1.ObjectMeta{
Name: "default",
},
Spec: kbv1aplha1.QueueSpec{
Weight: 1,
},
}
// create fake volcano clientset
KubeBatchClientSet = kubebatchclient.NewSimpleClientset()

//create default queue
_, err := KubeBatchClientSet.SchedulingV1alpha1().Queues().Create(&defaultqueue)
if err != nil {
t.Error("Queue Creation Failed")
}

ret := validateJob(testCase.Job, &testCase.reviewResponse)
//fmt.Printf("test-case name:%s, ret:%v testCase.reviewResponse:%v \n", testCase.Name, ret,testCase.reviewResponse)
if testCase.ExpectErr == true && ret == "" {
t.Errorf("%s: test case Expect error msg :%s, but got nil.", testCase.Name, testCase.ret)
}
if testCase.ExpectErr == true && testCase.reviewResponse.Allowed != false {
t.Errorf("%s: test case Expect Allowed as false but got true.", testCase.Name)
}
if testCase.ExpectErr == true && !strings.Contains(ret, testCase.ret) {
t.Errorf("%s: test case Expect error msg :%s, but got diff error %v", testCase.Name, testCase.ret, ret)
}
//create default queue
_, err := KubeBatchClientSet.SchedulingV1alpha2().Queues().Create(&defaultqueue)
if err != nil {
t.Error("Queue Creation Failed")
}

if testCase.ExpectErr == false && ret != "" {
t.Errorf("%s: test case Expect no error, but got error %v", testCase.Name, ret)
}
if testCase.ExpectErr == false && testCase.reviewResponse.Allowed != true {
t.Errorf("%s: test case Expect Allowed as true but got false. %v", testCase.Name, testCase.reviewResponse)
}
ret := validateJob(testCase.Job, &testCase.reviewResponse)
//fmt.Printf("test-case name:%s, ret:%v testCase.reviewResponse:%v \n", testCase.Name, ret,testCase.reviewResponse)
if testCase.ExpectErr == true && ret == "" {
t.Errorf("Expect error msg :%s, but got nil.", testCase.ret)
}
if testCase.ExpectErr == true && testCase.reviewResponse.Allowed != false {
t.Errorf("Expect Allowed as false but got true.")
}
if testCase.ExpectErr == true && !strings.Contains(ret, testCase.ret) {
t.Errorf("Expect error msg :%s, but got diff error %v", testCase.ret, ret)
}

if testCase.ExpectErr == false && ret != "" {
t.Errorf("Expect no error, but got error %v", ret)
}
if testCase.ExpectErr == false && testCase.reviewResponse.Allowed != true {
t.Errorf("Expect Allowed as true but got false. %v", testCase.reviewResponse)
}
})
}

}
8 changes: 4 additions & 4 deletions pkg/cli/queue/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

vkapi "volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
schedulingV1alpha2 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha2"
"volcano.sh/volcano/pkg/client/clientset/versioned"
)

Expand Down Expand Up @@ -50,17 +50,17 @@ func CreateQueue() error {
return err
}

queue := &vkapi.Queue{
queue := &schedulingV1alpha2.Queue{
ObjectMeta: metav1.ObjectMeta{
Name: createQueueFlags.Name,
},
Spec: vkapi.QueueSpec{
Spec: schedulingV1alpha2.QueueSpec{
Weight: int32(createQueueFlags.Weight),
},
}

queueClient := versioned.NewForConfigOrDie(config)
if _, err := queueClient.SchedulingV1alpha1().Queues().Create(queue); err != nil {
if _, err := queueClient.SchedulingV1alpha2().Queues().Create(queue); err != nil {
return err
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/queue/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/spf13/cobra"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha2"
"volcano.sh/volcano/pkg/client/clientset/versioned"
)

Expand Down Expand Up @@ -57,7 +57,7 @@ func GetQueue() error {
}

queueClient := versioned.NewForConfigOrDie(config)
queue, err := queueClient.SchedulingV1alpha1().Queues().Get(getQueueFlags.Name, metav1.GetOptions{})
queue, err := queueClient.SchedulingV1alpha2().Queues().Get(getQueueFlags.Name, metav1.GetOptions{})
if err != nil {
return err
}
Expand All @@ -68,7 +68,7 @@ func GetQueue() error {
}

// PrintQueue prints queue information
func PrintQueue(queue *v1alpha1.Queue, writer io.Writer) {
func PrintQueue(queue *v1alpha2.Queue, writer io.Writer) {
_, err := fmt.Fprintf(writer, "%-25s%-8s%-8s%-8s%-8s\n",
Name, Weight, Pending, Running, Unknown)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/queue/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/spf13/cobra"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha2"
"volcano.sh/volcano/pkg/client/clientset/versioned"
)

Expand Down Expand Up @@ -64,7 +64,7 @@ func ListQueue() error {
}

jobClient := versioned.NewForConfigOrDie(config)
queues, err := jobClient.SchedulingV1alpha1().Queues().List(metav1.ListOptions{})
queues, err := jobClient.SchedulingV1alpha2().Queues().List(metav1.ListOptions{})
if err != nil {
return err
}
Expand All @@ -79,7 +79,7 @@ func ListQueue() error {
}

// PrintQueues prints queue information
func PrintQueues(queues *v1alpha1.QueueList, writer io.Writer) {
func PrintQueues(queues *v1alpha2.QueueList, writer io.Writer) {
_, err := fmt.Fprintf(writer, "%-25s%-8s%-8s%-8s%-8s\n",
Name, Weight, Pending, Running, Unknown)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cli/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import (
"net/http"
"net/http/httptest"
"testing"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha2"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
)

func getTestQueueHTTPServer(t *testing.T) *httptest.Server {

response := v1alpha1.Queue{}
response := v1alpha2.Queue{}

response.Name = "testQueue"
response.Spec.Weight = int32(2)
Expand Down
Loading

0 comments on commit 71ad4ce

Please sign in to comment.