Stop paying for the task list when the API serves logs #270
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/actions-log-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fj run view --logreads job logs from/api/v1/repos/{o}/{r}/actions/jobs/{id}/logson Forgejo 16, with a plain API token. It was still fetching the workflow task list first and then discarding it. That call is not cheap on 16:/actions/tasksignores itsrunfilter there, so it answers with every task in the repository. Against a private repo on 16.0.3 that is 3.2 MB and about 30 seconds, paid on every single log read.Only the Loki fallback ever needed task metadata (the per-task container name and the query window). It now comes from a
TaskSourcethat loads on first ask, so the native path never asks at all. The task id the output reports on that path comes from the jobs payload, which carries it inline.Two related things the 16 path got wrong, fixed here because the same change surfaces them:
parse_workflow_tasksdid not know about theworkflow_runsenvelope the task list actually arrives in, so the Loki fallback aborted with "unexpected workflow task list response shape" rather than falling back.private_log_auth_errorand theworkflow_view.rsmodule header both still said the API log route does not exist and rejects token auth. That was true of 15.0.2 and is not true of 16.0.3. They now say which version does what, so the message points at--loginstead of sending the user to the web UI.15.x loses nothing. The API route 404s there and the run falls through to Loki exactly as it did before, which is the behaviour the existing fallback tests cover.
Refs #103.
Verified on macOS:
cargo fmt --checkclean,cargo clippy --all-targets --all-features -- -D warningsclean,cargo test --allgreen (797 + 5 + 1),cargo auditclean.Forgejo 16 serves job logs from `/api/v1/repos/{o}/{r}/actions/jobs/{id}/logs` with a plain API token, which is the path `fj run view --log` takes there. It was still fetching the workflow task list first and then throwing the result away: `/actions/tasks` ignores its `run` filter on 16, so that call answers with every task in the repository. Measured against a private repo on 16.0.3: 3.2 MB and about 30 seconds, on every log read. Only the Loki fallback needs task metadata (the per-task container name and the query window), so it is now fetched behind a `TaskSource` that loads on first ask, and the native path never asks. The task id the output reports on that path comes from the jobs payload instead, which carries it inline. Two things that path gets wrong on 16 are fixed alongside: * `parse_workflow_tasks` did not know the `workflow_runs` envelope the task list actually comes back in, so the Loki fallback aborted with "unexpected workflow task list response shape". * `private_log_auth_error` and the `workflow_view.rs` module header still described the API log route as nonexistent and token-rejecting, which was true of 15.0.2 and is not true of 16.0.3. Both now say which version does what, so the message points at `--log` rather than at the web UI. 15.x keeps every fallback it had: the API route 404s there, and the run falls through to Loki exactly as before. Refs rasterstate/fj#103