Skip to content

Add canceling state for jobs

Allison Browne requested to merge 399215-add-canceling-state-for-jobs into master

What does this MR do and why?

This MR adds a canceling state which a processable will transition to prior to the cancelled state when the flag is on.

The eventual outcome is that, while the job is in the canceling state the after_script will run on the runner. This will require some runner updates which are captured in gitlab-runner#30827 (closed). The feature flag ci_canceling_status should not be enabled until that is complete.

For now this is WIP and not meant to be turned on until:

  1. We have runner support for the cancelling status gitlab-runner#30827 (closed)
  2. We account for or ensure that older versions of runner will not have issues with handling the canceling state.

This will come in other MRs and issues in the epic.

Screenshots or screen recordings

Before After
Screenshot_2024-01-24_at_11.42.19_AM Screenshot_2024-01-24_at_11.38.45_AM
Screenshot_2024-01-24_at_11.52.54_AM Screenshot_2024-01-24_at_11.29.50_AM

How to set up and validate locally

  1. In rails console enable the feature flag
    Feature.enable(:ci_canceling_status)
  2. Create a pipeline with jobs to cancel:
    job1:
      script: sleep 60
  3. Start the pipeline and wait for the job to be 'running'
  4. Find the job in the rails console and send the cancel signal(or via the ui):
    [2] pry(main)> CommitStatus.find_by_id(2584).status
    => "running"
    CommitStatus.find_by_id(2584).cancel!
    => "canceling"
  5. Observe that the job is marked as canceling
  6. Observe that the pipeline is marked as canceling
  7. Observe that the job transitions to canceled

Related to #399215 (closed)

Edited by Allison Browne

Merge request reports