From 89d17bcf676751ebe68dab546ae2513c8044ac39 Mon Sep 17 00:00:00 2001 From: xilinxing Date: Thu, 22 Sep 2022 11:20:37 +0800 Subject: [PATCH] fix plugin use listers listing resource failed Signed-off-by: xilinxing --- installer/helm/chart/volcano/templates/scheduler.yaml | 9 ++++++--- installer/volcano-development-arm64.yaml | 10 +++++++--- installer/volcano-development.yaml | 9 ++++++--- pkg/scheduler/cache/cache.go | 7 +++++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/installer/helm/chart/volcano/templates/scheduler.yaml b/installer/helm/chart/volcano/templates/scheduler.yaml index 650390bff5a..6d0a234f70d 100644 --- a/installer/helm/chart/volcano/templates/scheduler.yaml +++ b/installer/helm/chart/volcano/templates/scheduler.yaml @@ -43,8 +43,8 @@ rules: resources: ["persistentvolumes"] verbs: ["list", "watch"] - apiGroups: [""] - resources: ["namespaces"] - verbs: ["list", "watch"] + resources: ["namespaces", "services", "replicationcontrollers"] + verbs: ["list", "watch", "get"] - apiGroups: [""] resources: ["resourcequotas"] verbs: ["list", "watch"] @@ -72,6 +72,9 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get", "create", "delete", "update"] + - apiGroups: ["apps"] + resources: ["daemonsets", "replicasets", "statefulsets"] + verbs: ["list", "watch", "get"] --- kind: ClusterRoleBinding @@ -138,7 +141,7 @@ metadata: prometheus.io/port: "8080" prometheus.io/scrape: "true" name: {{ .Release.Name }}-scheduler-service - namespace: {{ .Release.Namespace }} + namespace: {{ .Release.Namespace }} spec: ports: - port: 8080 diff --git a/installer/volcano-development-arm64.yaml b/installer/volcano-development-arm64.yaml index 53928962cc9..c9988435904 100644 --- a/installer/volcano-development-arm64.yaml +++ b/installer/volcano-development-arm64.yaml @@ -134,6 +134,7 @@ spec: priorityClassName: system-cluster-critical containers: - args: + - --enabled-admission=/jobs/mutate,/jobs/validate,/podgroups/mutate,/pods/validate,/pods/mutate,/queues/mutate,/queues/validate - --tls-cert-file=/admission.local.config/certificates/tls.crt - --tls-private-key-file=/admission.local.config/certificates/tls.key - --ca-cert-file=/admission.local.config/certificates/ca.crt @@ -8565,8 +8566,8 @@ rules: resources: ["persistentvolumes"] verbs: ["list", "watch"] - apiGroups: [""] - resources: ["namespaces"] - verbs: ["list", "watch"] + resources: ["namespaces", "services", "replicationcontrollers"] + verbs: ["list", "watch", "get"] - apiGroups: [""] resources: ["resourcequotas"] verbs: ["list", "watch"] @@ -8594,6 +8595,9 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get", "create", "delete", "update"] + - apiGroups: ["apps"] + resources: ["daemonsets", "replicasets", "statefulsets"] + verbs: ["list", "watch", "get"] --- # Source: volcano/templates/scheduler.yaml kind: ClusterRoleBinding @@ -8618,7 +8622,7 @@ metadata: prometheus.io/port: "8080" prometheus.io/scrape: "true" name: volcano-scheduler-service - namespace: volcano-system + namespace: volcano-system spec: ports: - port: 8080 diff --git a/installer/volcano-development.yaml b/installer/volcano-development.yaml index 6431557a625..9b8eef61997 100644 --- a/installer/volcano-development.yaml +++ b/installer/volcano-development.yaml @@ -8566,8 +8566,8 @@ rules: resources: ["persistentvolumes"] verbs: ["list", "watch"] - apiGroups: [""] - resources: ["namespaces"] - verbs: ["list", "watch"] + resources: ["namespaces", "services", "replicationcontrollers"] + verbs: ["list", "watch", "get"] - apiGroups: [""] resources: ["resourcequotas"] verbs: ["list", "watch"] @@ -8595,6 +8595,9 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get", "create", "delete", "update"] + - apiGroups: ["apps"] + resources: ["daemonsets", "replicasets", "statefulsets"] + verbs: ["list", "watch", "get"] --- # Source: volcano/templates/scheduler.yaml kind: ClusterRoleBinding @@ -8619,7 +8622,7 @@ metadata: prometheus.io/port: "8080" prometheus.io/scrape: "true" name: volcano-scheduler-service - namespace: volcano-system + namespace: volcano-system spec: ports: - port: 8080 diff --git a/pkg/scheduler/cache/cache.go b/pkg/scheduler/cache/cache.go index 4c447747504..2138cc1b4ee 100644 --- a/pkg/scheduler/cache/cache.go +++ b/pkg/scheduler/cache/cache.go @@ -640,6 +640,13 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu UpdateFunc: sc.UpdateNumaInfoV1alpha1, DeleteFunc: sc.DeleteNumaInfoV1alpha1, }) + // explictly register informers to the factory, otherwise resources listers cannot get anything + // even with no erorr returned. + informerFactory.Core().V1().Namespaces().Informer() + informerFactory.Core().V1().Services().Informer() + informerFactory.Core().V1().ReplicationControllers().Informer() + informerFactory.Apps().V1().ReplicaSets().Informer() + informerFactory.Apps().V1().StatefulSets().Informer() return sc }