|
77 | 77 |
|
78 | 78 | SUPPORTED_CLUSTER_MANAGERS = ['kubernetes', 'local'] |
79 | 79 | 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' |
83 | 86 |
|
84 | 87 | log = logging.Logger(__name__) |
85 | 88 | log.setLevel(logging.WARN) |
@@ -308,7 +311,7 @@ def _get_k8s_spark_env( |
308 | 311 | service_account_name: Optional[str] = None, |
309 | 312 | include_self_managed_configs: bool = True, |
310 | 313 | k8s_server_address: Optional[str] = None, |
311 | | - user: Optional[str] = USER_UNSPECIFIED, |
| 314 | + user: Optional[str] = USER_LABEL_UNSPECIFIED, |
312 | 315 | jira_ticket: Optional[str] = None, |
313 | 316 | ) -> Dict[str, str]: |
314 | 317 | # RFC 1123: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names |
@@ -1057,15 +1060,15 @@ def get_spark_conf( |
1057 | 1060 | user = user or os.environ.get('USER', None) |
1058 | 1061 |
|
1059 | 1062 | 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 |
1061 | 1064 | if needs_jira_check: |
1062 | 1065 | valid_ticket = self._get_valid_jira_ticket(jira_ticket) |
1063 | 1066 | if valid_ticket is None: |
1064 | 1067 | error_msg = ( |
1065 | 1068 | 'Job requires a valid Jira ticket (format PROJ-1234).\n' |
1066 | 1069 | 'Please pass the parameter as: paasta spark-run --jira-ticket=PROJ-1234 \n' |
1067 | 1070 | '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' |
1069 | 1072 | ) |
1070 | 1073 | raise RuntimeError(error_msg) |
1071 | 1074 | else: |
|
0 commit comments