Skip to content
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

MLCOMPUTE-1389 | remove spark.app.id and generate static spark.app.name #3923

Merged
merged 6 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paasta_tools/kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ def limit_size_with_hash(name: str, limit: int = 63, suffix: int = 4) -> str:
"""
if len(name) > limit:
digest = hashlib.md5(name.encode()).digest()
hash = base64.b32encode(digest).decode().replace("=", "").lower()
return f"{name[:(limit-suffix-1)]}-{hash[:suffix]}"
hashed = base64.b32encode(digest).decode().replace("=", "").lower()
return f"{name[:(limit-suffix-1)]}-{hashed[:suffix]}"
else:
return name

Expand Down
10 changes: 10 additions & 0 deletions paasta_tools/tron_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,16 @@ def build_spark_config(self) -> Dict[str, str]:
),
user=spark_tools.SPARK_JOB_USER,
)
# delete the dynamically generated spark.app.id to prevent frequent config updates in Tron.
# spark.app.id will be generated later by yelp spark-submit wrapper or Spark itself.
spark_conf.pop("spark.app.id", None)
# use a static spark.app.name to prevent frequent config updates in Tron.
# md5 and base64 will always generate the same encoding for a string.
# This spark.app.name might be overridden by yelp spark-submit wrapper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a sourcegraph search for repo:^sysgit/yelpsoa-configs$ spark.app.name it seems like some folks set short static app names, so we may want to follow this up with a follow-up PR that allows static/user-set app names to continue being set if that's something we want to support

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also auto set by spark-etl jobs - sourcegraph: repo:spark_etl$ spark.app.name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this

if "spark.app.name" in spark_conf:
spark_conf["spark.app.name"] = limit_size_with_hash(
f"tron_spark_{self.get_service()}_{self.get_instance()}_{self.get_action_name()}"
)
# TODO: Remove this once dynamic pod template is generated inside the driver using spark-submit wrapper
if "spark.kubernetes.executor.podTemplateFile" in spark_conf:
print(
Expand Down
4 changes: 0 additions & 4 deletions tests/test_tron_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,12 +1216,9 @@ def test_format_tron_action_dict_spark(

confs = result["command"].split(" ")
spark_app_name = ""
spark_app_id = ""
for s in confs:
if s.startswith("spark.app.name"):
spark_app_name = s.split("=")[1]
if s.startswith("spark.app.id"):
spark_app_id = s.split("=")[1]

expected = {
"command": "timeout 12h spark-submit "
Expand All @@ -1230,7 +1227,6 @@ def test_format_tron_action_dict_spark(
"--conf spark.executor.memory=1g "
"--conf spark.executor.cores=2 "
f"--conf spark.app.name={spark_app_name} "
f"--conf spark.app.id={spark_app_id} "
"--conf spark.ui.port=39091 "
"--conf spark.executor.instances=0 "
"--conf spark.kubernetes.executor.limit.cores=2 "
Expand Down
Loading