3131 end
3232 end
3333
34+ def spark_ui_config
35+ if context.spark_version >= '3.4.1'
36+ {
37+ "spark.ui.reverseProxy" => "true",
38+ "spark.ui.reverseProxyUrl" => "/rnode/${SPARK_MASTER_HOST}/${SPARK_MASTER_WEBUI_PORT}",
39+ "spark.ui.enabled" => "true",
40+ "spark.ui.killEnabled" => "false",
41+ "spark.ui.filters" => "edu.osc.spark.AuthFilter",
42+ }
43+ else
44+ {}
45+ end
46+ end
47+
3448 def exec_memory
3549 calculated = avail_mem/context.num_workers.to_i
3650 [60, calculated].min
3751 end
3852
3953 spark_config = {
40- "spark.ui.reverseProxy" => "true",
41- #"spark.ui.reverseProxyUrl" => "https://ondemand.osc.edu/node/${SPARK_MASTER_HOST}/${SPARK_MASTER_WEBUI_PORT}",
4254 "spark.authenticate" => "true",
4355 "spark.authenticate.secret" => "${SPARK_SECRET}",
44- # Comment out below when reverse proxy and authentication are added
45- # This still starts the Web UI on the master/worker procs, but disables it for
46- # the Application driver
47- "spark.ui.enabled" => "false",
48- # So we need to disable the ability to kill applications
49- "spark.ui.killEnabled" => "false",
50- }.merge(extra_spark_config)
56+ }.merge(extra_spark_config).merge(spark_ui_config)
5157
5258 def pyspark_submit_args
5359 args = []
@@ -73,6 +79,9 @@ port=$(find_port ${host})
7379SALT="$(create_passwd 16)"
7480password="$(create_passwd 16)"
7581PASSWORD_SHA1="$(echo -n "${password}${SALT}" | openssl dgst -sha1 | awk '{print $NF}')"
82+ export SPARK_UI_AUTH_TOKEN=$(uuid)
83+ export spark_ui_auth_token=$SPARK_UI_AUTH_TOKEN
84+ export spark_version=<%= context.spark_version %>
7685
7786# Notebook root directory
7887export NOTEBOOK_ROOT="${NOTEBOOK_ROOT:-${HOME}}"
@@ -147,6 +156,8 @@ mkdir "${LOG_ROOT}"
147156export SPARK_MASTER_HOST=${host}
148157export SPARK_MASTER_PORT=$(find_port ${SPARK_MASTER_HOST})
149158export SPARK_MASTER_WEBUI_PORT=$(find_port ${SPARK_MASTER_HOST})
159+ export spark_master_webui_port=$SPARK_MASTER_WEBUI_PORT
160+ export spark_master_host=$SPARK_MASTER_HOST
150161
151162# Generate Spark secret
152163SPARK_SECRET="$(create_passwd)"
0 commit comments