Skip to content

Show why a job failed when it never uploaded its own report - #114921

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:ci-show-reason-for-job-with-no-report
Aug 17, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:ci-show-reason-for-job-with-no-report

Conversation

@groeneai

@groeneai groeneai commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not user-facing: CI report only.

Description

Two jobs on #113382 lost their runner mid-Run, and both report pages render nothing, so
the failure looks like a 0-second job with no output:

praktika did detect the failure and record the reason, but three defects hide it.

_finish_workflow reported such a job only through
env.add_workflow_error(..., source=result.name). source= sets the from label, not the
destination, so the message landed on the workflow node while the job's own node kept an
empty info, and the page renders notifications from the node it resolved, which is the
job. The Status.ERROR sites in runner.py already call add_error on the job's own
result; this site did not.

A job uploads its own result_<job>.json from inside the job, so a job that dies never
uploads one and S3 answers 403. The page turned that 403 into "Report does not exist or
expired" and returned, discarding the workflow report it had already fetched, which does
contain the job's node. That early return is gone, and the cached per-job report is now
overwritten on every fetch that came back, so a page polling sha=latest cannot keep
showing an older commit's node.

Rendering that node exposed a third defect, already on master: the auto-reload predicate
asked whether the per-job report was running, so a null one read as still loading and the
page refetched S3 every 30 seconds forever. It now asks the node the page actually renders.

The runner loss is not fixable here and this does not try to.

A test drives _finish_workflow against a stubbed environment and asserts the reason reaches
the uploaded workflow report. For the page, a script extracts the relevant functions from
json.html and replays the measured S3 responses. Reverting any one fix alone reintroduces
its symptom; the healthy and expired paths stay byte-identical.

groeneai and others added 2 commits August 14, 2026 23:26
Two jobs on ClickHouse#113382 lost their runner mid-Run and both report pages render
nothing, so the failure looks like a 0-second job with no output.

praktika did detect the failure and did record the reason, but two defects hide
it, and either one alone is enough to blank the page.

_finish_workflow reported a job that never finalized only through
env.add_workflow_error(..., source=result.name). The source= argument sets the
"from" label, not the destination, so the message went to the workflow node
while the job's own node kept an empty info. The report page renders
notifications from the node it resolved, which is the job, so it had nothing to
show. The other Status.ERROR sites in runner.py already call add_error on the
job's own result; this site did not.

A job uploads its own result_<job>.json from inside the job, so a job that dies
never uploads one and S3 answers 403. The page turned that 403 into "Report does
not exist or expired" and returned, discarding the workflow report it had
already fetched, which does contain the job's node. The 403 check for the
workflow report itself is left alone: if that one is gone, the report really is
gone.

The runner loss itself is not fixable here and this does not try to. Only the
reporting is changed.

Validated with a script that extracts fetchJson, runtimeCache, getTargetResults
and fetchData from json.html and replays the measured S3 responses. Pre-fix the
page bails; with only the native_jobs.py change it still bails; with only the
json.html change it shows the job with no reason; with both it shows the
message. The healthy path and the genuinely-expired path are byte-identical to
before. The new test in ci/tests/test_result.py fails with KeyError: 'errors'
if Result.add_error is neutered, so it is a live check rather than a restatement.

runner.py:675 records an artifact-upload failure the same way, but it runs
in-job, so its report is uploaded and its page is not blank. Left out to keep
this to one root cause.

Related: ClickHouse#113382

Co-Authored-By: Claude Opus <[email protected]>
… path

Review round 1 on the same change. Two corrections, no redesign.

The per-job report cache was only written when the fetch was not a 403, so a
403 left the previous commit's node in it. getTargetResults prefers that cached
node, so a page polling sha=latest would show an older run's status and info as
if it were the current commit's, with no notification panel. That is worse than
the dead end it replaced. fetchJson already returns a null payload on a 403, so
restoring the plain "if (updated)" guard both keeps the 403 non-fatal and clears
the stale entry. The 403 check for the workflow report is still untouched.

The regression test called Result.add_error and Result.from_dict directly. Both
are unchanged here, so the test passed on an unpatched tree and could not fail
for the reason the change exists. It now drives _finish_workflow itself and
asserts on the JSON that Result.dump wrote, which is the file the uploader
ships, so it also covers the annotation reaching the report rather than only the
in-memory object. It fails with KeyError: 'errors' when the added line is
deleted, and on a pristine tree at the merge base with only the test dropped in.

The comment on the native_jobs.py call is dropped; it described the fix rather
than the code. The json.html comment now states what the line does.

Related: ClickHouse#113382

Co-Authored-By: Claude Opus <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds, 2 blockers/majors fixed before publishing)

Two review rounds against this change. Round 1 found and fixed one blocker and one major;
round 2 is clean.

Round 1

❌ blocker: a per-job 403 left a previous commit's job node cached. The first draft made
the per-job 403 non-fatal but also skipped the cache write on 403, so a page polling
sha=latest kept showing an earlier commit's node for that job, with its old info and no
reason, presented as the current commit's result. That is worse than the blank page it
replaced. Fixed: the cache write is now the plain if (updated), the same shape the code had
before this change, so a fetch that came back always overwrites, and fetchJson already
yields data: null on 403. Verified by replaying the measured S3 responses through the
functions extracted from json.html: the new commit's node is shown, the healthy and both
expired paths are byte-identical to before, and re-adding the skipped write brings the stale
node back.

❌ major: the regression test did not exercise the changed line. The first test called
Result.add_error and Result.from_dict directly, both unchanged, and never reached
_finish_workflow. It passed on a pristine checkout of the merge base with only the test
added. Replaced with a test that calls _finish_workflow against a stubbed environment and
asserts on the JSON its S3 stub writes, which is the file that gets uploaded. It fails with
KeyError: 'errors' when the added line is removed, and fails on the merge base.

💡 nit: dropped a comment that only made sense if you already knew what defect this fixes.

Round 2

Clean, no findings. Checked independently: the workflow report is reloaded from S3 each
Finish Workflow run, but the branch is guarded by not result.is_completed() and the same
run sets ERROR, so the annotation cannot be appended twice; no other code path writes
another job's ext["errors"]; the newly-rendered node has duration: null, no links and no
sub-results, and every widget on that path already early-returns on those; json1 has one
writer and two readers and both tolerate null today.

Scope deliberately left alone: the runner loss itself is not fixable here, and
runner.py:675 sets ERROR without annotating the job's own node, which is a real sibling
but does not blank a page (that job uploads its own report), so it is not bundled here.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, two oracles, both sub-second and fully deterministic. Python layer: _finish_workflow is driven end to end against a stubbed environment and S3, and the assertion reads the JSON that Result.dump() actually wrote, which is the file the uploader ships. Render layer: a script extracts fetchJson, runtimeCache, storeLink, getTargetResults and fetchData verbatim from json.html and replays the measured S3 responses (result_pr.json 200, result_<job>.json 403), then asserts what renderNotificationPanels would receive.
b Root cause explained? Yes. A runner dies mid-Run, so the in-job upload never happens and result_<job>.json is absent (403). _finish_workflow recorded the reason only through env.add_workflow_error(..., source=...), whose source= sets the from label and not the destination, so it landed on the workflow node while the job node kept info: ''. json.html renders panels from the resolved job node, and separately bailed out on the per-job 403 before rendering anything at all. Either defect alone blanks the page.
c Fix matches root cause? Yes, one line at each layer that owns its defect: record the reason on the job's own result, and stop treating a missing per-job report as a missing report. No widened bound, no defensive guard. Deliberately excluded: runner retries, any hardening of the runner loss, changes to the fuzzer job, and fabricating a per-job JSON for a job that never ran.
d Test intent preserved / new tests added? New test added: ci/tests/test_result.py::test_unfinished_job_carries_its_own_error_in_the_workflow_report. It calls the changed function, _finish_workflow, and asserts on the serialized workflow report that the dead job's node carries the reason, that its status is ERROR, that the healthy sibling is untouched, and that the workflow-level attribution is still emitted (so a future cleanup that drops it reddens here). Nothing existing was weakened. Placed in test_result.py because #114675 deletes 66 other files under ci/tests/ and leaves this one.
e Both directions demonstrated? Yes. Python: the test passes on the fixed tree and FAILS with KeyError: 'errors' when the added line is deleted; it also fails on a pristine git archive of the merge-base with only the test file dropped in (that tree has 0 occurrences of the fix and 1 control occurrence of NOT_FINALIZED). Render: 3 arms. On the fixed tree the harness reports "shows the new commit's node" with the panel populated; re-adding the removed conjunct flips it back to showing a previous commit's node; and the 5-scenario matrix leaves the healthy and both expired rows byte-identical to base, changing only the two dead-runner rows.
f Fix is general across code paths? Yes. Re-enumerated every site that sets a child result to Status.ERROR in ci/praktika/. All seven runner.py sites already call add_error on the job's own result, two more set info (which does render), and the result.py hits are status aggregation rather than diagnosis sites. native_jobs.py was the only one with no job-level record other than runner.py:675, which runs in-job, does upload its own report, and therefore does not produce a blank page. That one is disclosed and deliberately left out to keep this PR to a single root cause.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. Matrix over the branch's whole reachable input space: both not-finalized statuses (PENDING, RUNNING) against five prior ext shapes (empty, run_url only, a pre-existing errors list, warnings, notes). The reason is carried in all ten and prior keys are preserved, never clobbered. Name boundaries 0, 1, 51, 400 characters and a name containing /:* all work and create no per-job file, which matters because _dump_if_persisted exists to avoid ENAMETOOLONG on names derived from long error messages. For the report page, the 5-scenario matrix covers healthy, both expiry modes and both dead-runner modes; only the dead-runner rows change.
h Backward compatible? (maintainer-approved exception only) Not engaged, and compatible in both directions. No setting, no serialization format version, no SettingsChangesHistory.cpp, no user-visible ClickHouse behaviour. ext is a free-form dict and errors is an already-rendered key. An old page reading a new report ignores the extra key; a new page reading an old report takes the unchanged path.
i Invariants and contracts preserved? Yes. No per-job file is created (add_error calls _dump_if_persisted, a no-op without an existing file), so no dump() was added. The annotation does reach the uploaded artifact: the test asserts against the file Result.dump() wrote, which is what copy_result_to_s3_with_version uploads. Cache freshness is now an invariant rather than an accident: the per-job cache entry is overwritten on every fetch that returned, so a page polling sha=latest cannot render a previous commit's node as the current one. All three reads of that entry were already null-guarded, so a null lands on a path written to tolerate it. update_sub_result(..., drop_nested_results=True) still replaces the node on a rerun, so no stale panel survives. No error or early-return path is touched.

Session id: cron:clickhouse-review-slot-8:20260815-014200

@clickhouse-gh

clickhouse-gh Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ca59bcb]

Summary: ✅


AI Review

Summary

This PR fixes Praktika report handling for jobs that die before uploading result_<job>.json: _finish_workflow now records the failure on the child node, the report page falls back to the workflow child instead of bailing on a per-job 403, and the auto-refresh predicate stops once that rendered child is terminal. I reviewed the current diff and prior discussion; the earlier refresh-loop issue is fixed, and I did not find any remaining correctness or contract issues in the updated code.

Final Verdict

✅ No findings.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this? When a runner dies mid-Run the job never uploads its own result_<job>.json, so praktika wrote the reason to the workflow node while the page renders notifications from the job node, and separately bailed out on that per-job 403 before rendering anything, leaving the check page blank.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 15, 2026
Comment thread ci/praktika/json.html Resolved
Making a missing result_<job>.json render the workflow-report node left the
auto-reload predicate looking at runtimeCache.json1, which stays null on that
path. A dead-runner job page therefore rendered a terminal ERROR node and kept
refetching S3 every 30 seconds with nothing left to observe.

The predicate now reads the node the page actually renders, which is what
getTargetResults resolves: json1 when the per-job report exists, otherwise the
matching child of the workflow report. Healthy pages short-circuit on json1 and
are unaffected, and an unresolved target still keeps polling so a cold or
partially-loaded cache is not mistaken for a finished job.

Measured with the render-layer replay harness over five S3 states, driving the
fetchData/getTargetResults/runtimeCache units and the predicate extracted
verbatim from json.html. Only the dead-runner row changes: it settles on the
first tick instead of polling forever. Reverting just the predicate restores the
old behaviour, and the other four states are byte-identical to master.
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing ca59bcbb2 with master 36b4a90c4 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 693.25 MiB 690.24 MiB -3.02 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ca59bcb

CI has fully finished on this head and there are no failures. The praktika report is
OK at the top level with 0 dropped jobs, all 7 executed checks passed (Config
Workflow, Style check, Code Review, CI Tests, Build (arm_release), Build profile diff,
Finish Workflow), and CIDB records zero FAIL/ERROR test rows for this commit. The
remaining jobs were skipped by the usual config rules, each with a stated reason
("Not affected by the changed files and not required", "no build-affecting changes",
"not labeled with 'pr-performance'", "not a bug-fix PR", "reused from cache"), not
dropped. That is expected here: the diff is confined to ci/praktika/json.html,
ci/praktika/native_jobs.py and ci/tests/test_result.py.

Check / test Reason Owner / fixing PR
(none) - -

Session id: cron:our-pr-ci-monitor:20260815-060000

@alexey-milovidov alexey-milovidov self-assigned this Aug 17, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 17, 2026
Merged via the queue into ClickHouse:master with commit 71a917a Aug 17, 2026
181 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 17, 2026
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 2026
alexey-milovidov pushed a commit to soda4fries/ClickHouse that referenced this pull request Aug 19, 2026
On PR ClickHouse#90117 head cbac4ce, Config Workflow
errored and 174 jobs were DROPPED, so nothing ran on that head. The report shows
a JSONDecodeError from get_pr_title_body_labels. That is not the cause: it is
handled at gh.py:911-921, which prints "Failed to get PR data", stores the
traceback and returns ("", "", []), after which native_jobs.py:600-614 guards on
"if title:". The job then ran for another 62 seconds and died at
native_jobs.py:635 with "Failed to set both GH commit status and PR comment with
Workflow Status, cannot proceed", after GitHub answered HTTP 503 to a PATCH of
the report comment and a POST of the commit status.

That fatal exception never reached the report. Info.store_traceback appends
handled tracebacks to env.TRACEBACKS, and Runner._post_run renders those as the
job's info. The __main__ handler here is the only frame holding the fatal
traceback, and it built its Result with the info= argument commented out on the
stated assumption that runner._run() generates info for every job. It does not
for this class of job: the log-tail fallback at runner.py:505-521 is gated on
"not result.is_completed()", and is_completed() is "status not in (PENDING,
RUNNING)", so an ERROR result is already completed and skips it. A native job
that dies by exception therefore reports whichever handled traceback happened to
be stored earlier, or nothing at all.

The traceback is truncated because an exception message can carry command output
of any size: gh.py:170-181 raises a RuntimeError whose message interpolates the
command, exit code, stderr and stdout with no cap, and that is the
retry-exhaustion path a GitHub outage takes. gh.py:271 and gh.py:504 do elide
their fields; that one does not. Truncation keeps the tail, because for an
ordinary short message that is where the type and the message are. Those same
uncapped multi-line messages invert that: format_exc emits the "Type: message"
line ahead of the remaining message lines, so once the message exceeds the line
budget the surviving window starts past it and the report becomes an unlabelled
excerpt of command output. The type and the first message line are therefore
kept ahead of the truncated traceback. That shape is reachable from inside the
region this handler wraps: native_jobs.py:693 calls _check_db outside any try,
which reads a secret through Shell.get_output(strict=True) and raises from
utils.py:193-195 with raw multi-line stderr interpolated and no cap.

set_info appends, and the handler dumps before _post_run re-reads and appends
TRACEBACKS, so the fatal traceback lands first and no existing text is lost.

Breadth: 24 PRs took a Config Workflow error on 2026-08-17, 12 of them at this
line. I fetched the reports for 8 of the 12 and none showed the fatal error: 5
show the misleading JSONDecodeError and 3 show a completely empty info. Each
dropped 174 jobs. One of the 12 reached the same line with no 503 at all, its gh
calls exiting 4 for a missing GH_TOKEN, so this reports whatever the cause was
rather than assuming a 5xx.

Only the reporting is changed. The retry budget is untouched, and so is the
"res1 or res2" predicate at the fatal site: whether losing the commit status is
survivable when the report comment landed is a design question I am not deciding
here. native_jobs.py:747 loses a reason in the same family, assigning the return
value of traceback.print_exc() so that sub-result's info is the literal "None".
Left out to keep this to one root cause.

The new test drives the real __main__ block through runpy with only
mangle._get_workflows replaced by a raiser, and asserts against the Result the
job dumps to disk. The ordering case additionally runs Runner._post_run, so the
append of env.TRACEBACKS is executed rather than modelled: every remote-facing
step of _post_run is opt-in per workflow, so a bare Workflow.Config reaches it
with no network. All three cases fail on the current code, and each half of the
change has its own live oracle: removing only the identifying prefix reddens the
bound test alone, and deleting only the append at runner.py:787-788 reddens the
ordering test alone. Two tests were dropped along the way for measuring the
harness rather than the product. One asserted the pre-fix empty info but passed
with the change neutered. The other was an earlier ordering test that called
set_info itself instead of running _post_run, so it stayed green with that
append deleted.

The handler is shared, so _finish_workflow, the docker build jobs and the "BUG,
job name" branch are covered too. Jobs that die without raising are already
handled by ClickHouse#114921 and are not touched. Regular ci/jobs scripts are unaffected:
the runner dumps a RUNNING result before a job, so one that dies leaves
is_completed() false and runner.py:511 does fire for it. That asymmetry is the
defect.

Related: ClickHouse#90117

Co-Authored-By: Claude Opus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants