Skip to content
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
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ issues:
linters:
- gomnd
- dupl
- path: pkg/apis/scheduling/v1beta1/conversion.go
linters:
- golint
- path: generated
linters:
- golint
- path: fake
linters:
- golint
1 change: 0 additions & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ volcano.sh/volcano/pkg/scheduler/actions/enqueue
volcano.sh/volcano/pkg/scheduler/actions/preempt
volcano.sh/volcano/pkg/scheduler/actions/reclaim
volcano.sh/volcano/pkg/webhooks/admission/jobs/mutate
volcano.sh/volcano/pkg/webhooks/admission/queues/mutate
volcano.sh/volcano/pkg/webhooks/router
volcano.sh/volcano/pkg/webhooks/schema
volcano.sh/volcano/test/e2e
20 changes: 10 additions & 10 deletions pkg/scheduler/actions/allocate/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ import (
"volcano.sh/volcano/pkg/scheduler/util"
)

type allocateAction struct {
type Action struct {
ssn *framework.Session
}

func New() *allocateAction {
return &allocateAction{}
func New() *Action {
return &Action{}
}

func (alloc *allocateAction) Name() string {
func (alloc *Action) Name() string {
return "allocate"
}

func (alloc *allocateAction) Initialize() {}
func (alloc *Action) Initialize() {}

func (alloc *allocateAction) Execute(ssn *framework.Session) {
func (alloc *Action) Execute(ssn *framework.Session) {
klog.V(3).Infof("Enter Allocate ...")
defer klog.V(3).Infof("Leaving Allocate ...")

Expand Down Expand Up @@ -126,11 +126,11 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
// because the allocation of job would change the priority of queue among all namespaces,
// and the PriorityQueue have no ability to update priority for a special queue.
var queue *api.QueueInfo
for queueId := range queueInNamespace {
currentQueue := ssn.Queues[queueId]
for queueID := range queueInNamespace {
currentQueue := ssn.Queues[queueID]
if ssn.Overused(currentQueue) {
klog.V(3).Infof("Namespace <%s> Queue <%s> is overused, ignore it.", namespace, currentQueue.Name)
delete(queueInNamespace, queueId)
delete(queueInNamespace, queueID)
continue
}

Expand Down Expand Up @@ -251,4 +251,4 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
}
}

func (alloc *allocateAction) UnInitialize() {}
func (alloc *Action) UnInitialize() {}
14 changes: 7 additions & 7 deletions pkg/scheduler/actions/backfill/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ import (
"volcano.sh/volcano/pkg/scheduler/framework"
)

type backfillAction struct {
type Action struct {
ssn *framework.Session
}

func New() *backfillAction {
return &backfillAction{}
func New() *Action {
return &Action{}
}

func (alloc *backfillAction) Name() string {
func (alloc *Action) Name() string {
return "backfill"
}

func (alloc *backfillAction) Initialize() {}
func (alloc *Action) Initialize() {}

func (alloc *backfillAction) Execute(ssn *framework.Session) {
func (alloc *Action) Execute(ssn *framework.Session) {
klog.V(3).Infof("Enter Backfill ...")
defer klog.V(3).Infof("Leaving Backfill ...")

Expand Down Expand Up @@ -90,4 +90,4 @@ func (alloc *backfillAction) Execute(ssn *framework.Session) {
}
}

func (alloc *backfillAction) UnInitialize() {}
func (alloc *Action) UnInitialize() {}
16 changes: 8 additions & 8 deletions pkg/scheduler/actions/enqueue/enqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ var (
defaultOverCommitFactor = 1.2
)

type enqueueAction struct {
type Action struct {
ssn *framework.Session
}

func New() *enqueueAction {
return &enqueueAction{}
func New() *Action {
return &Action{}
}

func (enqueue *enqueueAction) Name() string {
func (enqueue *Action) Name() string {
return "enqueue"
}

func (enqueue *enqueueAction) Initialize() {}
func (enqueue *Action) Initialize() {}

func (enqueue *enqueueAction) Execute(ssn *framework.Session) {
func (enqueue *Action) Execute(ssn *framework.Session) {
klog.V(3).Infof("Enter Enqueue ...")
defer klog.V(3).Infof("Leaving Enqueue ...")

Expand Down Expand Up @@ -135,9 +135,9 @@ func (enqueue *enqueueAction) Execute(ssn *framework.Session) {
}
}

func (enqueue *enqueueAction) UnInitialize() {}
func (enqueue *Action) UnInitialize() {}

func (enqueue *enqueueAction) getOverCommitFactor(ssn *framework.Session) float64 {
func (enqueue *Action) getOverCommitFactor(ssn *framework.Session) float64 {
factor := defaultOverCommitFactor
arg := framework.GetArgOfActionFromConf(ssn.Configurations, enqueue.Name())
if arg != nil {
Expand Down
14 changes: 7 additions & 7 deletions pkg/scheduler/actions/preempt/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ import (
"volcano.sh/volcano/pkg/scheduler/util"
)

type preemptAction struct {
type Action struct {
ssn *framework.Session
}

func New() *preemptAction {
return &preemptAction{}
func New() *Action {
return &Action{}
}

func (alloc *preemptAction) Name() string {
func (alloc *Action) Name() string {
return "preempt"
}

func (alloc *preemptAction) Initialize() {}
func (alloc *Action) Initialize() {}

func (alloc *preemptAction) Execute(ssn *framework.Session) {
func (alloc *Action) Execute(ssn *framework.Session) {
klog.V(3).Infof("Enter Preempt ...")
defer klog.V(3).Infof("Leaving Preempt ...")

Expand Down Expand Up @@ -174,7 +174,7 @@ func (alloc *preemptAction) Execute(ssn *framework.Session) {
}
}

func (alloc *preemptAction) UnInitialize() {}
func (alloc *Action) UnInitialize() {}

func preempt(
ssn *framework.Session,
Expand Down
14 changes: 7 additions & 7 deletions pkg/scheduler/actions/reclaim/reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ import (
"volcano.sh/volcano/pkg/scheduler/util"
)

type reclaimAction struct {
type Action struct {
ssn *framework.Session
}

func New() *reclaimAction {
return &reclaimAction{}
func New() *Action {
return &Action{}
}

func (alloc *reclaimAction) Name() string {
func (ra *Action) Name() string {
return "reclaim"
}

func (alloc *reclaimAction) Initialize() {}
func (ra *Action) Initialize() {}

func (alloc *reclaimAction) Execute(ssn *framework.Session) {
func (ra *Action) Execute(ssn *framework.Session) {
klog.V(3).Infof("Enter Reclaim ...")
defer klog.V(3).Infof("Leaving Reclaim ...")

Expand Down Expand Up @@ -197,5 +197,5 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) {

}

func (ra *reclaimAction) UnInitialize() {
func (ra *Action) UnInitialize() {
}
4 changes: 2 additions & 2 deletions pkg/webhooks/admission/jobs/mutate/mutate_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func init() {

var service = &router.AdmissionService{
Path: "/jobs/mutate",
Func: MutateJobs,
Func: Jobs,

MutatingConfig: &whv1beta1.MutatingWebhookConfiguration{
Webhooks: []whv1beta1.MutatingWebhook{{
Expand All @@ -71,7 +71,7 @@ type patchOperation struct {
}

// MutateJobs mutate jobs
func MutateJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
func Jobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
klog.V(3).Infof("mutating jobs")

job, err := schema.DecodeJob(ar.Request.Object, ar.Request.Resource)
Expand Down
6 changes: 3 additions & 3 deletions pkg/webhooks/admission/queues/mutate/mutate_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {

var service = &router.AdmissionService{
Path: "/queues/mutate",
Func: MutateQueues,
Func: Queues,

MutatingConfig: &whv1beta1.MutatingWebhookConfiguration{
Webhooks: []whv1beta1.MutatingWebhook{{
Expand All @@ -62,8 +62,8 @@ type patchOperation struct {
Value interface{} `json:"value,omitempty"`
}

// MutateQueues mutate queues
func MutateQueues(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
// Queues mutate queues
func Queues(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
klog.V(3).Infof("Mutating %s queue %s.", ar.Request.Operation, ar.Request.Name)

queue, err := schema.DecodeQueue(ar.Request.Object, ar.Request.Resource)
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhooks/admission/queues/mutate/mutate_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func TestMutateQueues(t *testing.T) {

for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
reviewResponse := MutateQueues(testCase.AR)
reviewResponse := Queues(testCase.AR)
if !reflect.DeepEqual(reviewResponse, testCase.reviewResponse) {
t.Errorf("Test case '%s' failed, expect: %v, got: %v", testCase.Name,
reviewResponse, testCase.reviewResponse)
Expand Down
38 changes: 19 additions & 19 deletions test/e2e/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package e2e
import (
"encoding/json"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -29,9 +29,9 @@ import (
schedulingv1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1"
)

var _ = Describe("Job E2E Test: Test Admission service", func() {
var _ = ginkgo.Describe("Job E2E Test: Test Admission service", func() {

It("Default queue would be added", func() {
ginkgo.It("Default queue would be added", func() {
jobName := "job-default-queue"
ctx := initTestContext(options{})
defer cleanupTestContext(ctx)
Expand All @@ -50,14 +50,14 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
},
},
})
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())
createdJob, err := ctx.vcclient.BatchV1alpha1().Jobs(ctx.namespace).Get(jobName, v1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
Expect(createdJob.Spec.Queue).Should(Equal("default"),
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(createdJob.Spec.Queue).Should(gomega.Equal("default"),
"Job queue attribute would default to 'default' ")
})

It("Invalid CPU unit", func() {
ginkgo.It("Invalid CPU unit", func() {
ctx := initTestContext(options{})
defer cleanupTestContext(ctx)

Expand Down Expand Up @@ -98,13 +98,13 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
}
}`)
err := json.Unmarshal(jsonData, &job)
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())
_, err = ctx.vcclient.BatchV1alpha1().Jobs(ctx.namespace).Create(&job)
Expect(err).To(HaveOccurred())
gomega.Expect(err).To(gomega.HaveOccurred())

})

It("Invalid memory unit", func() {
ginkgo.It("Invalid memory unit", func() {
ctx := initTestContext(options{})
defer cleanupTestContext(ctx)

Expand Down Expand Up @@ -146,13 +146,13 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
}`)

err := json.Unmarshal(jsonData, &job)
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())
_, err = ctx.vcclient.BatchV1alpha1().Jobs(ctx.namespace).Create(&job)
Expect(err).To(HaveOccurred())
gomega.Expect(err).To(gomega.HaveOccurred())

})

It("Create default-scheduler pod", func() {
ginkgo.It("Create default-scheduler pod", func() {
podName := "pod-default-scheduler"
ctx := initTestContext(options{})
defer cleanupTestContext(ctx)
Expand All @@ -172,13 +172,13 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
}

_, err := ctx.kubeclient.CoreV1().Pods(ctx.namespace).Create(pod)
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())

err = waitPodPhase(ctx, pod, []corev1.PodPhase{corev1.PodRunning})
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())
})

It("Can't create volcano pod when podgroup is Pending", func() {
ginkgo.It("Can't create volcano pod when podgroup is Pending", func() {
podName := "pod-volcano"
pgName := "pending-pg"
ctx := initTestContext(options{})
Expand Down Expand Up @@ -215,9 +215,9 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
}

_, err := ctx.vcclient.SchedulingV1beta1().PodGroups(ctx.namespace).Create(pg)
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())

_, err = ctx.kubeclient.CoreV1().Pods(ctx.namespace).Create(pod)
Expect(err.Error()).Should(ContainSubstring(`the podgroup phase is Pending`))
gomega.Expect(err.Error()).Should(gomega.ContainSubstring(`the podgroup phase is Pending`))
})
})
2 changes: 1 addition & 1 deletion test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ func waitPodGone(ctx *context, podName, namespace string) error {
_, err := ctx.kubeclient.CoreV1().Pods(namespace).Get(podName, metav1.GetOptions{})
expected := errors.IsNotFound(err)
if !expected {
additionalError = fmt.Errorf("Job related pod should be deleted when aborting job.")
additionalError = fmt.Errorf("job related pod should be deleted when aborting job")
}

return expected, nil
Expand Down