-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting spark.app.id to a more intuitive name #124
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import logging | ||
import math | ||
import os | ||
import re | ||
import time | ||
from typing import Any | ||
from typing import Dict | ||
|
@@ -37,6 +38,7 @@ | |
|
||
NON_CONFIGURABLE_SPARK_OPTS = { | ||
'spark.master', | ||
'spark.app.id', | ||
'spark.ui.port', | ||
'spark.mesos.principal', | ||
'spark.mesos.secret', | ||
|
@@ -1076,20 +1078,27 @@ def get_spark_conf( | |
_pick_random_port(PREFERRED_SPARK_UI_PORT), | ||
) | ||
|
||
spark_conf = {**(spark_opts_from_env or {}), **_filter_user_spark_opts(user_spark_opts)} | ||
|
||
if aws_creds[2] is not None: | ||
spark_conf['spark.hadoop.fs.s3a.aws.credentials.provider'] = AWS_ENV_CREDENTIALS_PROVIDER | ||
|
||
# app_name from env is already appended port and time to make it unique | ||
app_name = (spark_opts_from_env or {}).get('spark.app.name') | ||
if not app_name: | ||
# We want to make the app name more unique so that we can search it | ||
# from history server. | ||
app_name = f'{app_base_name}_{ui_port}_{int(time.time())}' | ||
|
||
spark_conf = {**(spark_opts_from_env or {}), **_filter_user_spark_opts(user_spark_opts)} | ||
|
||
if aws_creds[2] is not None: | ||
spark_conf['spark.hadoop.fs.s3a.aws.credentials.provider'] = AWS_ENV_CREDENTIALS_PROVIDER | ||
# Explicitly setting app id: replace special characters to '_' to make it consistent | ||
# in all places for metric systems: | ||
# - since in the Promehteus metrics endpoint those will be converted to '_' | ||
# - while the 'spark-app-selector' executor pod label will keep the original app id | ||
app_id = re.sub(r'[\.,-]', '_', app_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I missed it earlier. |
||
|
||
spark_conf.update({ | ||
'spark.app.name': app_name, | ||
'spark.app.id': app_id, | ||
'spark.ui.port': str(ui_port), | ||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for moving the following lines down a bit for better code readability: