Draft: [Design review] Failed jobs widget kept current by subscriptions, backend and frontend
What does this MR do and why?
Fixes #606907
On the MR Pipelines tab, with mr_pipelines_graphql enabled, retrying a failed job did not reliably update the failed jobs badge and the expanded list. This MR is the complete solution in one place, backend and frontend, so the design can be reviewed as a whole before it is split for delivery. It is not meant to merge as is: the backend trigger is not behind a flag here, and the frontend assumes ci_stage_subscription and clear_action_cable_loader are on.
It restarts !253179 (closed) by @sasharma13. The design work and most of the frontend code are Sahil's.
Why the widget got stuck
- The widget owned a count query that polled only while the pipeline was active. Once the pipeline failed, polling stopped, and a retry from the stage dropdown never reached the widget.
- Row subscriptions tracked only "alive" pipelines. Finished pipelines are retryable, so they must stay subscribed while displayed.
- A retry that leaves the stage running, or a job that fails while the pipeline keeps running, changes the failed jobs without any pipeline status transition. No subscription payload described those changes.
What keeps the widget current now
Every change the widget shows arrives as a subscription payload. Nothing is read after a user action except the downstream list, see below.
- Backend.
ciPipelineStatusUpdatedis also triggered when a commit status entersfailedand when a new attempt marks older attempts asretried. Both are bounded by failures and retries, not by every job event. The jobs resolver preloads job definitions and pipelines so a failed list does not issue one query per job. - Row. The pipeline row owns the failed jobs count and passes it to the widget, which mounts only when the count is positive. The count includes bridge and external failures, matching the list.
- Subscriptions. Every displayed pipeline is subscribed while visible, plus up to three displayed downstreams per row. A renderless
pipeline_status_subscription.vuedeclares one subscription per instance, taking the pipeline and adownstreamflag, and the wrapper renders one beside the table per row and per downstream. Mounting subscribes, unmounting unsubscribes, and Vue's list diffing replaces the hand-written set reconciliation. The expanded failed jobs list and an open stage dropdown use declarativesubscribeToMorewhile mounted. - Fallback. When websocket delivery is unavailable, rows and an open stage dropdown poll every 60 seconds and an open failed jobs list every 10, all visibility-aware.
What the frontend looks like after the cleanup
- The shared pipelines table no longer knows about the widget. It exposes a
row-detailsscoped slot, and each MR wrapper renders the widget in it with its own data shape. Rows carry_showDetails, the bootstrap-vue details flag, set by the wrapper. TheuseFailedJobsWidgetinject is gone. - The job action button no longer runs mutations. It emits
job-action-requestedwith the action type, and a renderlessjob_action.vuewrapped around each job list runs the mutation, tracks per-job loading, and emitsjob-action-executed. It outlives a row that a realtime payload replaces mid-action, which is what the original promise-passing event worked around. - The wrapper derives its view from two booleans: whether the first response for the requested page has arrived, and whether it failed. The template is a
v-ifchain: loading, error, empty, table. A poll or refetch never changes the view. A failed refresh keeps the rows and shows a warning above the table. - Removed: the widget's count query, the MR-specific retry mutation document, the single pipeline query and the rereads that used it, the
retriedevent chain from the job row up to the table, the alive-status bookkeeping and its constant, and the wrapper'si18nblock.
The one read that remains
Playing a manual bridge creates a downstream pipeline that nothing has subscribed to yet. The wrapper still reads the downstream list after a job action. Closing that gap needs a trigger on downstream creation and is out of scope here.
How to split for delivery
- The backend trigger merges first, behind its flag, as !257495 (closed).
- The frontend fix merges independently as !257267. It keeps the post-action rereads, so it works with the trigger off.
- The cleanup that drops the rereads becomes a follow-up once the trigger flag,
clear_action_cable_loader, andci_stage_subscriptionare on by default. - The declarative subscriptions, the loaded flag, the
v-ifchain and the inlined strings are flag-independent and can join the frontend delivery MR.
Verification
- Jest green under Vue 2 and Vue 3 for the MR pipelines, failure widget, common CI, mini graph and graph dropdown specs.
- Feature spec
spec/features/merge_request/user_sees_pipelines_spec.rb, failed jobs and real-time blocks, green locally against this branch. Its retry example also drops a running job and retries another failure from outside the browser, asserting the count and list follow with no reload. - Model spec for the two
CommitStatustriggers, green.
How to set up and validate locally
- Enable
mr_pipelines_graphql. Open an MR with two failed jobs and one running job in the same stage. Expand the widget. - Retry one failure from the stage dropdown. The count drops to 1, the list drops the retried job, the dropdown shows the new attempt. No request other than the mutation leaves the page.
- In a Rails console,
drop!the running job. The count rises and the list gains the job without a reload. - Retry the last failure from another browser or the API. The widget disappears here. Let the new attempt fail. The widget reappears with the new attempt's ID.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
References
- Fixes #606907
- Original MR by @sasharma13: !253179 (closed)
- Design discussion on why subscriptions alone were not enough: !253179 (comment 3801502875)
- Frontend delivery MR: !257267
- Backend delivery MR: !257495 (closed)
- Rollout of the trigger flag: #630685
- Stale subscription payloads fix, rolling out: #628832 (closed)
- Stage subscription rollout, closed: #581569 (closed)
- MR-scoped subscription follow-up: #628001