Skip to content

Commit

Permalink
feat: add hierarchical queues for capacity plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Rui-Gan <[email protected]>
  • Loading branch information
Rui-Gan committed Oct 30, 2024
1 parent 919df69 commit d285af2
Show file tree
Hide file tree
Showing 28 changed files with 1,932 additions and 208 deletions.
12 changes: 12 additions & 0 deletions cmd/webhook-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"volcano.sh/apis/pkg/apis/helpers"
"volcano.sh/apis/pkg/apis/scheduling/scheme"
informers "volcano.sh/apis/pkg/client/informers/externalversions"
"volcano.sh/volcano/cmd/webhook-manager/app/options"
"volcano.sh/volcano/pkg/kube"
commonutil "volcano.sh/volcano/pkg/util"
Expand Down Expand Up @@ -64,6 +65,9 @@ func Run(config *options.Config) error {

vClient := getVolcanoClient(restConfig)
kubeClient := getKubeClient(restConfig)
factory := informers.NewSharedInformerFactory(vClient, 0)
queueInformer := factory.Scheduling().V1beta1().Queues()
queueLister := queueInformer.Lister()

broadcaster := record.NewBroadcaster()
broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
Expand All @@ -72,6 +76,7 @@ func Run(config *options.Config) error {
if service.Config != nil {
service.Config.VolcanoClient = vClient
service.Config.KubeClient = kubeClient
service.Config.QueueLister = queueLister
service.Config.SchedulerNames = config.SchedulerNames
service.Config.Recorder = recorder
service.Config.ConfigData = admissionConf
Expand All @@ -95,6 +100,13 @@ func Run(config *options.Config) error {
stopChannel := make(chan os.Signal, 1)
signal.Notify(stopChannel, syscall.SIGTERM, syscall.SIGINT)

factory.Start(webhookServeError)
for informerType, ok := range factory.WaitForCacheSync(webhookServeError) {
if !ok {
return fmt.Errorf("failed to sync cache: %v", informerType)
}
}

server := &http.Server{
Addr: config.ListenAddress + ":" + strconv.Itoa(config.Port),
TLSConfig: configTLS(config, restConfig),
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 @@ -55,7 +55,7 @@ rules:
verbs: ["create", "update"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["queues"]
verbs: ["get", "list"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get"]
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 @@ -59,7 +59,7 @@ rules:
verbs: ["get", "create", "delete", "update"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["podgroups", "queues", "queues/status"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
- apiGroups: ["flow.volcano.sh"]
resources: ["jobflows", "jobtemplates"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
Expand Down
2 changes: 1 addition & 1 deletion installer/helm/chart/volcano/templates/scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ rules:
verbs: ["get", "list", "watch"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["queues"]
verbs: ["get", "list", "watch", "create", "delete"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["queues/status"]
verbs: ["update"]
Expand Down
6 changes: 3 additions & 3 deletions installer/volcano-development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ rules:
verbs: ["create", "update"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["queues"]
verbs: ["get", "list"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get"]
Expand Down Expand Up @@ -4319,7 +4319,7 @@ rules:
verbs: ["get", "create", "delete", "update"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["podgroups", "queues", "queues/status"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
- apiGroups: ["flow.volcano.sh"]
resources: ["jobflows", "jobtemplates"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
Expand Down Expand Up @@ -4497,7 +4497,7 @@ rules:
verbs: ["get", "list", "watch"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["queues"]
verbs: ["get", "list", "watch", "create", "delete"]
verbs: ["get", "list", "watch", "create", "delete", "update"]
- apiGroups: ["scheduling.incubator.k8s.io", "scheduling.volcano.sh"]
resources: ["queues/status"]
verbs: ["update"]
Expand Down
Loading

0 comments on commit d285af2

Please sign in to comment.