Skip to content

Commit

Permalink
Replace more special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
chi-yelp committed Aug 17, 2023
1 parent dbc8301 commit c0ef079
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions service_configuration_lib/spark_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import math
import os
import re
import time
from typing import Any
from typing import Dict
Expand Down Expand Up @@ -1089,10 +1090,11 @@ def get_spark_conf(
# from history server.
app_name = f'{app_base_name}_{ui_port}_{int(time.time())}'

# Explicitly setting app id: replace '-' to '_' to make it consistent in all places for metric systems:
# - since the Spark app id in Promehteus metrics will be converted to underscores,
# - while the 'spark-app-selector' executor pod label will keep the original app id.
app_id = app_name.replace('-', '_')
# 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)

spark_conf.update({
'spark.app.name': app_name,
Expand Down
3 changes: 2 additions & 1 deletion tests/spark_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import itertools
import json
import os
import re
import sys
from unittest import mock

Expand Down Expand Up @@ -1142,7 +1143,7 @@ def verify(output):
def assert_app_id(self):
def verify(output):
key = 'spark.app.id'
assert output[key] == output['spark.app.name'].replace('-', '_')
assert output[key] == re.sub(r'[\.,-]', '_', output['spark.app.name'])
return [key]
return verify

Expand Down

0 comments on commit c0ef079

Please sign in to comment.