From 8cb6c8035eabd73c045f4078b27fa35767e2a52c Mon Sep 17 00:00:00 2001 From: disaster37 Date: Thu, 9 Nov 2023 21:43:12 +0100 Subject: [PATCH] fix: fix issue #1723 about spark-operator not working with volcano on OCP (#1724) * fix: fix issue #1723 about spark-operator not working with volcano on OCP Signed-off-by: disaster37 * Update volcano_scheduler.go --------- Signed-off-by: disaster37 --- charts/spark-operator-chart/templates/rbac.yaml | 2 ++ manifest/spark-operator-install/spark-operator-rbac.yaml | 2 +- pkg/batchscheduler/volcano/volcano_scheduler.go | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/charts/spark-operator-chart/templates/rbac.yaml b/charts/spark-operator-chart/templates/rbac.yaml index c78a73df9..6f9b57292 100644 --- a/charts/spark-operator-chart/templates/rbac.yaml +++ b/charts/spark-operator-chart/templates/rbac.yaml @@ -85,8 +85,10 @@ rules: resources: - sparkapplications - sparkapplications/status + - sparkapplications/finalizers - scheduledsparkapplications - scheduledsparkapplications/status + - scheduledsparkapplications/finalizers verbs: - "*" {{- if .Values.batchScheduler.enable }} diff --git a/manifest/spark-operator-install/spark-operator-rbac.yaml b/manifest/spark-operator-install/spark-operator-rbac.yaml index ec613ad32..71a053b48 100644 --- a/manifest/spark-operator-install/spark-operator-rbac.yaml +++ b/manifest/spark-operator-install/spark-operator-rbac.yaml @@ -58,7 +58,7 @@ rules: resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations"] verbs: ["create", "get", "update", "delete"] - apiGroups: ["sparkoperator.k8s.io"] - resources: ["sparkapplications", "scheduledsparkapplications", "sparkapplications/status", "scheduledsparkapplications/status"] + resources: ["sparkapplications", "scheduledsparkapplications", "sparkapplications/status", "scheduledsparkapplications/status", "sparkapplications/finalizers", "scheduledsparkapplications/finalizers"] verbs: ["*"] - apiGroups: ["scheduling.volcano.sh"] resources: ["podgroups", "queues", "queues/status"] diff --git a/pkg/batchscheduler/volcano/volcano_scheduler.go b/pkg/batchscheduler/volcano/volcano_scheduler.go index 1e1495335..31179ebf2 100644 --- a/pkg/batchscheduler/volcano/volcano_scheduler.go +++ b/pkg/batchscheduler/volcano/volcano_scheduler.go @@ -115,9 +115,12 @@ func (v *VolcanoBatchScheduler) getAppPodGroupName(app *v1beta2.SparkApplication } func (v *VolcanoBatchScheduler) syncPodGroup(app *v1beta2.SparkApplication, size int32, minResource corev1.ResourceList) error { - var err error + var ( + err error + pg *v1beta1.PodGroup + ) podGroupName := v.getAppPodGroupName(app) - if pg, err := v.volcanoClient.SchedulingV1beta1().PodGroups(app.Namespace).Get(context.TODO(), podGroupName, metav1.GetOptions{}); err != nil { + if pg, err = v.volcanoClient.SchedulingV1beta1().PodGroups(app.Namespace).Get(context.TODO(), podGroupName, metav1.GetOptions{}); err != nil { if !errors.IsNotFound(err) { return err }