Skip to content

Commit ad0d9b8

Browse files
committed
Commit suggested changes
1 parent 0ff45c7 commit ad0d9b8

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

paasta_tools/spark_tools.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,30 @@ def get_spark_driver_monitoring_annotations(
234234
"""
235235
Returns Spark driver pod annotations - currently used for Prometheus metadata.
236236
"""
237-
annotations: Dict[str, str] = dict()
238-
239-
ui_port_str = spark_config.get("spark.ui.port", "")
240-
if ui_port_str != "":
241-
annotations["prometheus.io/port"] = ui_port_str
242-
annotations["prometheus.io/path"] = "/metrics/prometheus"
237+
annotations: Dict[str, str] = {}
238+
239+
ui_port_str = spark_config.get("spark.ui.port")
240+
if ui_port_str:
241+
annotations.update(
242+
{
243+
"prometheus.io/port": ui_port_str,
244+
"prometheus.io/path": "/metrics/prometheus",
245+
}
246+
)
243247

244248
paasta_service_non_truncated = spark_config.get(
245-
"spark.kubernetes.executor.annotation.paasta.yelp.com/service", ""
249+
"spark.kubernetes.executor.annotation.paasta.yelp.com/service"
246250
)
247251
paasta_instance_non_truncated = spark_config.get(
248-
"spark.kubernetes.executor.annotation.paasta.yelp.com/instance", ""
252+
"spark.kubernetes.executor.annotation.paasta.yelp.com/instance"
249253
)
250-
if paasta_service_non_truncated != "" and paasta_instance_non_truncated != "":
251-
annotations["paasta.yelp.com/service"] = paasta_service_non_truncated
252-
annotations["paasta.yelp.com/instance"] = paasta_instance_non_truncated
254+
if paasta_service_non_truncated and paasta_instance_non_truncated:
255+
annotations.update(
256+
{
257+
"paasta.yelp.com/service": paasta_service_non_truncated,
258+
"paasta.yelp.com/instance": paasta_instance_non_truncated,
259+
}
260+
)
253261

254262
return annotations
255263

0 commit comments

Comments
 (0)