Skip to content

Commit 58f5b62

Browse files
committed
Bug 1970363 - add task ID and run ID to log messages about errors during schema validation for pulse and task data
1 parent c0c569a commit 58f5b62

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

treeherder/etl/job_loader.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ def _is_valid_job(self, pulse_job):
245245
pulse_job["owner"] = pulse_job["owner"][0:49]
246246
jsonschema.validate(pulse_job, get_json_schema("pulse-job.yml"))
247247
except (jsonschema.ValidationError, jsonschema.SchemaError) as e:
248-
logger.error("JSON Schema validation error during job ingestion: %s", e)
248+
if "taskId" in pulse_job:
249+
(real_task_id, run_id) = task_and_retry_ids(pulse_job["taskId"])
250+
else:
251+
real_task_id = "unknown"
252+
run_id = "unknown"
253+
logger.error(
254+
f"JSON Schema validation error during job ingestion for task {real_task_id}, run {run_id}: {e}"
255+
)
249256
return False
250257
return True

treeherder/etl/taskcluster_pulse/handler.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,19 @@ def parse_route_info(prefix, task_id, routes, task):
8585
return parsed_route
8686

8787

88-
def validate_task(task):
88+
def validate_task(task, task_id, run_id):
8989
treeherder_metadata = task.get("extra", {}).get("treeherder")
9090
if not treeherder_metadata:
91-
logger.debug("Task metadata is missing Treeherder job configuration.")
91+
logger.debug(
92+
f"Task metadata is missing Treeherder job configuration for task {task_id}, run {run_id}"
93+
)
9294
return False
9395
try:
9496
jsonschema.validate(treeherder_metadata, get_json_schema("task-treeherder-config.yml"))
9597
except (jsonschema.ValidationError, jsonschema.SchemaError) as e:
96-
logger.error("JSON Schema validation error during Taskcluser message ingestion: %s", e)
98+
logger.error(
99+
f"JSON Schema validation error during Taskcluser message ingestion for task {task_id}, run {run_id}: {e}"
100+
)
97101
return False
98102
return True
99103

@@ -168,6 +172,7 @@ async def handle_message(message, task_definition=None):
168172
async with taskcluster.aio.createSession() as session:
169173
jobs = []
170174
task_id = message["payload"]["status"]["taskId"]
175+
run_id = message["payload"]["runId"]
171176
async_queue = taskcluster.aio.Queue({"rootUrl": message["root_url"]}, session=session)
172177
task = (await async_queue.task(task_id)) if not task_definition else task_definition
173178

@@ -183,7 +188,7 @@ async def handle_message(message, task_definition=None):
183188
logger.debug("Message received for task %s", task_id)
184189

185190
# Validation failures are common and logged, so do nothing more.
186-
if not validate_task(task):
191+
if not validate_task(task, task_id, run_id):
187192
return jobs
188193

189194
task_type = EXCHANGE_EVENT_MAP.get(message["exchange"])

0 commit comments

Comments
 (0)