Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #604 from k82cn/mv_default_impl
Browse files Browse the repository at this point in the history
Moved default implementation from pkg.
  • Loading branch information
k8s-ci-robot authored Mar 1, 2019
2 parents 958864c + 002948b commit ff790cd
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
4 changes: 4 additions & 0 deletions cmd/kube-batch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (

"github.com/kubernetes-sigs/kube-batch/cmd/kube-batch/app"
"github.com/kubernetes-sigs/kube-batch/cmd/kube-batch/app/options"

// Import default actions/plugins.
_ "github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions"
_ "github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")
Expand Down
33 changes: 33 additions & 0 deletions pkg/scheduler/actions/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package actions

import (
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"

"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/preempt"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/reclaim"
)

func init() {
framework.RegisterAction(reclaim.New())
framework.RegisterAction(allocate.New())
framework.RegisterAction(backfill.New())
framework.RegisterAction(preempt.New())
}
12 changes: 7 additions & 5 deletions pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ func (sc *SchedulerCache) Evict(taskInfo *kbapi.TaskInfo, reason string) error {
}
}()

sc.Recorder.Eventf(job.PodGroup, v1.EventTypeNormal, "Evict", reason)
if !kbapi.ShadowPodGroup(job.PodGroup) {
sc.Recorder.Eventf(job.PodGroup, v1.EventTypeNormal, "Evict", reason)
}

return nil
}
Expand Down Expand Up @@ -541,16 +543,16 @@ func (sc *SchedulerCache) Snapshot() *kbapi.ClusterInfo {
}

if _, found := snapshot.Queues[value.Queue]; !found {
glog.V(3).Infof("The Queue <%v> of Job <%v> does not exist, ignore it.",
value.Queue, value.UID)
glog.V(3).Infof("The Queue <%v> of Job <%v/%v> does not exist, ignore it.",
value.Queue, value.Namespace, value.Name)
continue
}

snapshot.Jobs[value.UID] = value.Clone()
}

glog.V(3).Infof("There are <%d> Jobs and <%d> Queues in total for scheduling.",
len(snapshot.Jobs), len(snapshot.Queues))
glog.V(3).Infof("There are <%d> Jobs, <%d> Queues and <%d> Nodes in total for scheduling.",
len(snapshot.Jobs), len(snapshot.Queues), len(snapshot.Nodes))

return snapshot
}
Expand Down
17 changes: 3 additions & 14 deletions pkg/scheduler/factory.go → pkg/scheduler/plugins/factory.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,22 +14,17 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package scheduler
package plugins

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/preempt"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/actions/reclaim"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"

"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/drf"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/gang"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/predicates"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/prioritize"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/priority"
"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/proportion"

"github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework"
)

func init() {
Expand All @@ -42,10 +37,4 @@ func init() {

// Plugins for Queues
framework.RegisterPluginBuilder("proportion", proportion.New)

// Actions
framework.RegisterAction(reclaim.New())
framework.RegisterAction(allocate.New())
framework.RegisterAction(backfill.New())
framework.RegisterAction(preempt.New())
}
9 changes: 6 additions & 3 deletions pkg/scheduler/plugins/proportion/proportion.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,13 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
queue := obj.(*api.QueueInfo)
attr := pp.queueOpts[queue.UID]

glog.V(4).Infof("Queue <%v> is deserved <%v>, allocated <%v>",
queue.Name, attr.deserved, attr.allocated)
overused := attr.deserved.LessEqual(attr.allocated)
if overused {
glog.V(3).Infof("Queue <%v>: deserved <%v>, allocated <%v>, share <%v>",
queue.Name, attr.deserved, attr.allocated, attr.share)
}

return attr.deserved.LessEqual(attr.allocated)
return overused
})

// Register event handlers.
Expand Down

0 comments on commit ff790cd

Please sign in to comment.