@@ -324,6 +324,7 @@ pub async fn reconcile(
324324 & opt_s3conn,
325325 & logdir,
326326 & resolved_product_image,
327+ & serviceaccount,
327328 ) ?;
328329 client
329330 . apply_patch (
@@ -352,6 +353,7 @@ pub async fn reconcile(
352353 & opt_s3conn,
353354 & logdir,
354355 & resolved_product_image,
356+ & serviceaccount,
355357 ) ?;
356358 client
357359 . apply_patch (
@@ -363,13 +365,7 @@ pub async fn reconcile(
363365 . context ( ApplyApplicationSnafu ) ?;
364366
365367 let job_commands = spark_application
366- . build_command (
367- // TODO (@NickLarsenNZ): Explain this unwrap. Either convert to expect, or gracefully handle the error.
368- serviceaccount. metadata . name . as_ref ( ) . unwrap ( ) ,
369- & opt_s3conn,
370- & logdir,
371- & resolved_product_image. image ,
372- )
368+ . build_command ( & opt_s3conn, & logdir, & resolved_product_image. image )
373369 . context ( BuildCommandSnafu ) ?;
374370
375371 let submit_config = spark_application
@@ -593,6 +589,7 @@ fn pod_template(
593589 s3conn : & Option < s3:: v1alpha1:: ConnectionSpec > ,
594590 logdir : & Option < ResolvedLogDir > ,
595591 spark_image : & ResolvedProductImage ,
592+ service_account : & ServiceAccount ,
596593) -> Result < PodTemplateSpec > {
597594 let container_name = SparkContainer :: Spark . to_string ( ) ;
598595 let mut cb = ContainerBuilder :: new ( & container_name) . context ( IllegalContainerNameSnafu ) ?;
@@ -641,7 +638,8 @@ fn pod_template(
641638 . context ( AddVolumeSnafu ) ?
642639 . security_context ( security_context ( ) )
643640 . image_pull_secrets_from_product_image ( spark_image)
644- . affinity ( & config. affinity ) ;
641+ . affinity ( & config. affinity )
642+ . service_account_name ( service_account. name_any ( ) ) ;
645643
646644 let init_containers = init_containers (
647645 spark_application,
@@ -700,6 +698,7 @@ fn pod_template_config_map(
700698 s3conn : & Option < s3:: v1alpha1:: ConnectionSpec > ,
701699 logdir : & Option < ResolvedLogDir > ,
702700 spark_image : & ResolvedProductImage ,
701+ service_account : & ServiceAccount ,
703702) -> Result < ConfigMap > {
704703 let cm_name = spark_application. pod_template_config_map_name ( role. clone ( ) ) ;
705704
@@ -741,6 +740,7 @@ fn pod_template_config_map(
741740 s3conn,
742741 logdir,
743742 spark_image,
743+ service_account,
744744 ) ?;
745745
746746 let mut cm_builder = ConfigMapBuilder :: new ( ) ;
0 commit comments