Skip to content

Commit 5f0095a

Browse files
committed
Update constants and error_msg
1 parent 2a2d84d commit 5f0095a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

service_configuration_lib/spark_config.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@
7777

7878
SUPPORTED_CLUSTER_MANAGERS = ['kubernetes', 'local']
7979
DEFAULT_SPARK_RUN_CONFIG = '/nail/srv/configs/spark.yaml'
80-
USER_BATCH = 'batch' # used by batch servers
81-
USER_TRON = 'TRON' # used by Tron jobs, or other paasta CLI commands such as `paasta validate/mark-for-deployment`
82-
USER_UNSPECIFIED = 'UNSPECIFIED'
80+
TICKET_NOT_REQUIRED_USERS = {
81+
'batch', # non-human spark-run from batch boxes
82+
'TRON', # tronjobs that run commands like paasta mark-for-deployment
83+
None, # placeholder for being unable to determine user
84+
}
85+
USER_LABEL_UNSPECIFIED = 'UNSPECIFIED'
8386

8487
log = logging.Logger(__name__)
8588
log.setLevel(logging.WARN)
@@ -308,7 +311,7 @@ def _get_k8s_spark_env(
308311
service_account_name: Optional[str] = None,
309312
include_self_managed_configs: bool = True,
310313
k8s_server_address: Optional[str] = None,
311-
user: Optional[str] = USER_UNSPECIFIED,
314+
user: Optional[str] = USER_LABEL_UNSPECIFIED,
312315
jira_ticket: Optional[str] = None,
313316
) -> Dict[str, str]:
314317
# RFC 1123: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names
@@ -1057,15 +1060,15 @@ def get_spark_conf(
10571060
user = user or os.environ.get('USER', None)
10581061

10591062
if self.mandatory_default_spark_srv_conf.get('spark.yelp.jira_ticket.enabled') == 'true':
1060-
needs_jira_check = user not in [USER_BATCH, USER_TRON, None]
1063+
needs_jira_check = user not in TICKET_NOT_REQUIRED_USERS
10611064
if needs_jira_check:
10621065
valid_ticket = self._get_valid_jira_ticket(jira_ticket)
10631066
if valid_ticket is None:
10641067
error_msg = (
10651068
'Job requires a valid Jira ticket (format PROJ-1234).\n'
10661069
'Please pass the parameter as: paasta spark-run --jira-ticket=PROJ-1234 \n'
10671070
'For more information: https://yelpwiki.yelpcorp.com/spaces/AML/pages/402885641 \n'
1068-
'If you have questions, please reach out to #spark on Slack.\n'
1071+
f'If you have questions, please reach out to #spark on Slack. (user={user})\n'
10691072
)
10701073
raise RuntimeError(error_msg)
10711074
else:

0 commit comments

Comments
 (0)