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. ciPipelineStatusUpdated is also triggered when a commit status enters failed and when a new attempt marks older attempts as retried. 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.vue declares one subscription per instance, taking the pipeline and a downstream flag, 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 declarative subscribeToMore while 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-details scoped 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. The useFailedJobsWidget inject is gone.
  • The job action button no longer runs mutations. It emits job-action-requested with the action type, and a renderless job_action.vue wrapped around each job list runs the mutation, tracks per-job loading, and emits job-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-if chain: 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 retried event chain from the job row up to the table, the alive-status bookkeeping and its constant, and the wrapper's i18n block.

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, and ci_stage_subscription are on by default.
  • The declarative subscriptions, the loaded flag, the v-if chain 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 CommitStatus triggers, green.

How to set up and validate locally

  1. Enable mr_pipelines_graphql. Open an MR with two failed jobs and one running job in the same stage. Expand the widget.
  2. 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.
  3. In a Rails console, drop! the running job. The count rises and the list gains the job without a reload.
  4. 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

Edited by Miguel Rincon

Merge request reports

Loading
Loading