From 7fb14e629edbcfb0042de16cb9a2906b89eb980a Mon Sep 17 00:00:00 2001 From: Nick Tan Date: Mon, 7 Oct 2024 19:41:07 -0700 Subject: [PATCH] fix: imagePullPolicy was ignored (#2222) Signed-off-by: xuqingtan --- .../controller/sparkapplication/submission.go | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/internal/controller/sparkapplication/submission.go b/internal/controller/sparkapplication/submission.go index 318bb6e4f..a51bd2e4e 100644 --- a/internal/controller/sparkapplication/submission.go +++ b/internal/controller/sparkapplication/submission.go @@ -197,30 +197,27 @@ func dependenciesOption(app *v1beta2.SparkApplication) ([]string, error) { func imageOption(app *v1beta2.SparkApplication) ([]string, error) { var args []string - if app.Spec.Image == nil || *app.Spec.Image == "" { - return nil, nil + if app.Spec.Image != nil && *app.Spec.Image != "" { + args = append(args, + "--conf", + fmt.Sprintf("%s=%s", common.SparkKubernetesContainerImage, *app.Spec.Image), + ) } - args = append(args, - "--conf", - fmt.Sprintf("%s=%s", common.SparkKubernetesContainerImage, *app.Spec.Image), - ) - if app.Spec.ImagePullPolicy == nil || *app.Spec.ImagePullPolicy == "" { - return nil, nil + if app.Spec.ImagePullPolicy != nil && *app.Spec.ImagePullPolicy != "" { + args = append(args, + "--conf", + fmt.Sprintf("%s=%s", common.SparkKubernetesContainerImagePullPolicy, *app.Spec.ImagePullPolicy), + ) } - args = append(args, - "--conf", - fmt.Sprintf("%s=%s", common.SparkKubernetesContainerImagePullPolicy, *app.Spec.ImagePullPolicy), - ) - if len(app.Spec.ImagePullSecrets) == 0 { - return nil, nil + if len(app.Spec.ImagePullSecrets) > 0 { + secrets := strings.Join(app.Spec.ImagePullSecrets, ",") + args = append(args, + "--conf", + fmt.Sprintf("%s=%s", common.SparkKubernetesContainerImagePullSecrets, secrets), + ) } - secrets := strings.Join(app.Spec.ImagePullSecrets, ",") - args = append(args, - "--conf", - fmt.Sprintf("%s=%s", common.SparkKubernetesContainerImagePullSecrets, secrets), - ) return args, nil }