@@ -503,10 +503,11 @@ fn pod_template(
503503 logdir : & Option < ResolvedLogDir > ,
504504 spark_image : & ResolvedProductImage ,
505505 service_account : & ServiceAccount ,
506- // When set, the spark container runs this command (the spark-submit client invocation). This is
507- // used for the driver pod, which the operator now launches directly as a Kubernetes Job. When
508- // `None` (executor pod template), the container relies on the image entrypoint, since Spark sets
509- // the command on the executor pods it creates.
506+ // When set, the spark container runs this command (the spark-submit client invocation) as the
507+ // container `args`, leaving `command` unset so the image entrypoint (run-spark.sh) is used. This
508+ // is the driver pod, which the operator launches directly as a Kubernetes Job. When `None`
509+ // (executor pod template), the container also relies on the image entrypoint, since Spark sets
510+ // the args on the executor pods it creates.
510511 command : Option < & [ String ] > ,
511512) -> Result < PodTemplateSpec > {
512513 let container_name = SparkContainer :: Spark . to_string ( ) ;
@@ -543,14 +544,20 @@ fn pod_template(
543544 ) ) ;
544545 }
545546
546- cb. command ( vec ! [
547+ // We pass the spark-submit invocation as container `args` and leave `command` unset so the
548+ // image entrypoint (run-spark.sh) runs it. The entrypoint evaluates `_STACKABLE_PRE_HOOK`
549+ // (which starts containerdebug) before, and `_STACKABLE_POST_HOOK` (which writes the Vector
550+ // shutdown file) after the spark-submit process exits. The latter is what lets the Vector
551+ // agent terminate so the driver Job pod can complete. run-spark.sh delegates to Spark's
552+ // entrypoint.sh, which runs our `/bin/bash -c ...` in pass-through mode.
553+ cb. args ( vec ! [
547554 "/bin/bash" . to_string( ) ,
548555 "-x" . to_string( ) ,
549556 "-euo" . to_string( ) ,
550557 "pipefail" . to_string( ) ,
551558 "-c" . to_string( ) ,
559+ command. join( "\n " ) ,
552560 ] )
553- . args ( vec ! [ command. join( "\n " ) ] )
554561 . add_env_var ( "SPARK_SUBMIT_OPTS" , spark_submit_opts. join ( " " ) )
555562 // TODO: move this to the image
556563 . add_env_var ( "SPARK_CONF_DIR" , "/stackable/spark/conf" ) ;
@@ -909,6 +916,12 @@ fn driver_job(
909916 // A Job's pod must declare a restart policy.
910917 if let Some ( spec) = template. spec . as_mut ( ) {
911918 spec. restart_policy = Some ( "Never" . to_string ( ) ) ;
919+ // Give the driver pod a stable hostname ending in `-driver`. The Vector agent reports this
920+ // hostname as the `pod` field of every log event (see `log_schema.host_key: pod`), and log
921+ // aggregation/monitoring identifies driver logs by that `-driver` suffix. Without this the
922+ // Job controller's generated pod name (`<app>-<hash>`) would be used, which Spark previously
923+ // avoided by naming the cluster-mode driver pod `<app>-...-driver`.
924+ spec. hostname = Some ( spark_application. driver_service_name ( ) ) ;
912925 }
913926
914927 let job = Job {
0 commit comments