Skip to content

Fix conflict between canceling methods

Allison Browne requested to merge ab-canceling_event_name into master

What does this MR do and why?

Fix conflicts between canceling method names.

Active Record enum adds methods like canceling! for each status on a Stage.

We also defined canceling! as a state machine event which conflicts with the enum method.

Here we rename the event method from the state so we can take advantage of the state machine event controls and still transition to canceling.

For the CommitStatus it's safe to run cancel and have the event code determine when to transition to canceling or canceled based on what the current state is.

For the Stages and Pipelines, it's safer to directly set the status to canceling and canceled via start_cancel and finish_cancel:

  • since some processing happens ascync for the stages, pipelines
  • we can't depend on checking if canceling is supported for a pipeline or stage as easily since this is based on the builds runner. See build.supports_canceling which is set on the build_metadata.

I did not re-name all cancel's to finish_cancel in this MR as it would greatly increase the scope and risk of the change.

To verify

  1. Temporarily bring this MR into the branch: !150038 (merged)
  2. in the stages model make the change to move Importable above Ci::HasStatus:
    include Importable
    include Ci::HasStatus
  1. Run the static verification that failed locally: https://gitlab.com/gitlab-org/gitlab/-/jobs/6685075446#L884
source scripts/utils.sh
fail_on_warnings scripts/static-analysis
  1. It should pass.
  2. It should fail on the branch from this MR, with the same ruby model change
Edited by Allison Browne

Merge request reports