Draft: Keep MR failed jobs widget in sync with job retries
What does this MR do and why?
Fixes #606907
On the MR Pipelines tab, with mr_pipelines_graphql enabled, retrying a failed job does not reliably update the failed jobs badge and the expanded list.
This MR is a clean restart of !253179 (closed) by @sasharma13. The design work and the code are Sahil's. The original MR grew through 20 diff versions and 14 commits, and its branch still carried an early version of the backend fix that later merged in a different shape. This MR squashes the current state onto fresh master so we can refactor from a readable baseline.
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. A retry from the stage dropdown never reached the widget.
- The row subscriptions tracked only "alive" pipelines. Finished pipelines are retryable, so they must stay subscribed while they are displayed.
- A retry that leaves the stage running produces no pipeline or stage status transition. No subscription payload describes that change.
- Subscription payloads resolved with a stale
BatchLoader. That part is fixed on master in !254146 (merged), behindclear_action_cable_loader.
What changed
- The pipeline row owns the failed jobs count and passes it to the widget. The widget mounts only when the count is positive. The count now includes bridge and external failures, matching the list.
- Every displayed pipeline stays subscribed while visible, including up to three downstreams per parent. The alive and forced-alive bookkeeping is gone.
- The failed jobs list and the stage dropdown use declarative subscriptions while open, with visibility-aware polling as the fallback.
- Every consumer runs the shared
jobRetrydocument. The MR-specific mutation document and the provide/inject plumbing are gone. - The job action button no longer runs mutations. It emits
job-action-requestedwith the action type. A renderlessjob_action.vuecomponent wraps each job list, runs the mutation, tracks per-job loading, and emitsjob-action-executed. It is a child of the dropdown, so it outlives a row that a realtime payload replaces mid-action. - After a job action, the wrapper rereads the row and the open details of that pipeline. This covers the retries that no status payload describes.
- The jobs resolver preloads job definitions and pipelines to avoid per-job queries.
Changes compared to the original MR
- Dropped the
BatchLoader::Executor.clear_currentchange in the load-balancing subscription class and its spec. Master already has that fix as an ActionCable:workcallback. - The post-action reread is scoped to the affected pipeline. The original reread every open failed jobs list and stage dropdown on the page.
- The shared pipelines table no longer knows about the failed jobs widget. It exposes a
row-detailsscoped slot, and each MR wrapper renders the widget in it with its own data shape. TheuseFailedJobsWidgetinject and the_showDetailsmapping in the table are gone. The wrappers flag their rows with_showDetails, which is the bootstrap-vue contract the other tables in the codebase already use. - The mutation moved out of the leaf button into a renderless
job_action.vueowned by each dropdown. This replaces the original'sjob-action-startedevent that carried the pending promise, and removes the button's second completion event that two of three consumers ignored. The icon-to-mutation table is unchanged, only relocated. - The wrapper derives one
viewState(loading, error, empty, table) from Apollo'snetworkStatusinstead of three overlapping booleans. Only the first load and a page change show the spinner. A poll or refetch never changes the view, so an empty MR no longer flashes the spinner every minute, the pagination stays put during a poll, and a failed refresh keeps the last good rows with a warning above the table instead of replacing them with the error page. - Squashed to one commit.
Rollout blockers
Subscriptions alone keep the widget current only once these are on for the instance:
clear_action_cable_loader, so subscription payloads stop carrying stale counts. Rollout: #628832 (closed)ci_stage_subscription, so the stage dropdown receives job payloads. On for gitlab.com since 2026-03-09, stilldefault_enabled: falsefor self-managed. Rollout issue #581569 (closed) was closed citing cardinality issues.ci_pipeline_failed_jobs_subscription_trigger, so a failure or retry that leaves the pipeline status unchanged still reaches the row and the list. Added in !257495 (closed), rollout #630685
Until then this MR keeps the post-action rereads and polling as the fallback. Once all three are on, a follow-up removes the rereads.
Open design points to work on here
- Subscriptions, polling at three intervals, and post-action rereads overlap. Decide which scenario each covers, or drop one.
- The feature spec doubles the runtime of
user_sees_pipelines_spec.rb.
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 failed jobs widget. - Retry one failure from the stage dropdown. The count drops to 1, only the other failure remains in the widget, and the dropdown shows the new attempt.
- Repeat with
ci_stage_subscriptiondisabled. - Retry the last failure. The widget disappears. Let the new attempt fail. The widget reappears with the new attempt's ID.
- Repeat the last step with a retry started outside the browser.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
References
- Fixes #606907
- Restart of !253179 (closed) by @sasharma13
- Backend fix that merged separately: !254146 (merged)
- Rollout of
clear_action_cable_loader: #628832 (closed) - Review thread with the design discussion: !253179 (comment 3801502875)
- MR-scoped subscription follow-up: #628001
- Backend trigger so failures and retries reach the pipeline subscription: !257495 (closed)
- Rollout of that trigger: #630685
- Stage subscription flag rollout, closed: #581569 (closed)