Add auto-cancel for pending pipelines on branch, if they are not HEAD
What does this MR do?
Decrease entropy in Gitlab universe
First iteration for #8998 (closed)
-
Adds option "Auto-cancel pending pipelines" in "CI/CD Pipelines" project settings tab: when checkbox checked, all pending non-HEAD pipelines will be canceled by system, automatizing scenario:
1. "User creates pipeline for branch" / "User pushes commit to gitlab" 2. User goes to pipelines index page and cancel unnecessary (only pending) pipelines.
-
Adds
target: '_blank'
to doc links in "CI/CD Pipelines" project settings tab -
Refactor
spec/services/ci/create_pipeline_service_spec.rb
, extractingexecute_service
method
UI:
- Pipeline list:
-
Tooltip on canceled status badge
-
- MR widget/commit widget:
-
Pipeline #12345678 was auto-canceled.. etc
-
Hovering over the words auto-canceled
will bring the same tooltips
-
- Pipeline page:
-
Tooltip on canceled status badge
-
- Pipeline graph job node:
-
has improved tooltip with auto-canceled
(not anything else)
-
- Mini pipeline graph stage and job status icons
-
has improved tooltip with auto-canceled
(not anything else)
-
- Job list
-
Tooltip on canceled status badge
-
- Job list in pipeline view
-
Tooltip on canceled status badge
-
- Job view
-
Tooltip on canceled status badge
-
Are there points in the code the reviewer needs to double check?
Why was this MR needed?
Many reasons are discussed here #8998 (closed)
Screenshots (if relevant)
Option in CI/CD Pipelines Project settings tab:
Pipeline list:
Pipeline page:
Job list:
Job view:
Job list in pipeline view:
Setting:
Does this MR meet the acceptance criteria?
-
Changelog entry added -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Merge request reports
Activity
- Resolved by Lin Jen-Shin
- Resolved by Lin Jen-Shin
marked the task Changelog entry added as completed
added 61 commits
-
85a29bb0...91ac1991 - 60 commits from branch
gitlab-org:master
- 7ded70b8 - add auto-cancel for pending pipelines on branch, if they are not HEAD
-
85a29bb0...91ac1991 - 60 commits from branch
@innerwhisper Thank you for jumping into this. I think we also need a test to make sure that it's cancelling older created or pending pipelines. However in case you're not wasting any effort here, I would like to confirm with product people that what exactly we want here. I'll continue the discussion on the issue.
mentioned in issue #8998 (closed)
This feels like something that should have a project setting; not in
.gitlab.yml
. As long as it doesn't cancel a running pipeline, it should be pretty safe, but some people will want it disabled. Maybe by 10.0 we can make it default. And skip the branch filter, at least for first iteration.@markpundsack If we're doing this in 10.0, then I think we could build the options together.
@godfat I'm saying do it now, but keep defaults such that we don't change pipeline behavior in a negative way for people. We can easily change defaults at major upgrades. Although we can also change them earlier too, if they're generally improvements. In fact, for this particular change, I'd argue that it's better to have it on by default, and only turn it off if you're one of those users that wants every push built no matter how wasteful. But let's do at least one release with it optional before making that decision. We can enable it for
gitlab-ce
, test it out first-hand, and if it's overwhelmingly positive, then consider switching it on for everyone by default.I haven't looked at the implementation, but one thing I'd ask for is that when it is auto-canceled, someone hovering over the pipeline status will see an explanation, or at least some obvious indication that it was auto-canceled rather than manually canceled. I don't think that needs to be a primary status, just something on hover, for example. /cc @dimitrieh
@markpundsack So I think the remaining thing we should decide is where this option should go. In
.gitlab-ci.yml
or a project setting. @grzesiek said he prefers.gitlab-ci.yml
at https://gitlab.com/gitlab-org/gitlab-ce/issues/8998#note_23947692, and since I see this as harmless, I am ok with either way.don't think that needs to be a primary status
@markpundsack @godfat the first thing that pops up in my mind is a tag:
Edited by Dimitrie Hoekstra@dimitrieh That could work. What about in MR system information box and elsewhere that we reference pipeline status? Do we have space for a tag everywhere?
added 253 commits
-
7ded70b8...f106ad51 - 252 commits from branch
gitlab-org:master
- e94bca72 - add auto-cancel for pending pipelines on branch, if they are not HEAD
-
7ded70b8...f106ad51 - 252 commits from branch
@markpundsack ah good point... mmh
- Pipeline list: add a tag
- MR widget/commit widget: it can be pretty easily done by just saying something like
Pipeline #12345678 was auto-canceled.. etc
- Pipeline page: this is different thing.. as we are not yet showing tags (like
latest
) on the pipeline page it self.. So in the light of this issue perhaps this should be added, similar to the build page, which has support for tags: - Small individual pipeline status icons, like in project-list etc: Show this in the tooltip
test: auto-canceled
I think this should cover all places if i am correct for pipeline statuses.
cc: @godfat
Edited by Dimitrie Hoekstra- Pipeline list: add a tag
@dimitrieh The pipeline page should have room up above, in the title summary, without needing to add a tags line to the info box. But strangely, the title on pipeline pages doesn't mention the status in words other than the badge. Instead it focuses on when it was triggered.
But ignoring that for now:
It is interesting that we don't show the
latest
tag on the pipeline page anywhere, but also that no one has ever complained about it being missing. I'd guess it's most useful for deciding which pipeline to click on, and just not something that's important to show on the pipeline detail page itself.added 1 commit
- 5141f184 - add auto-cancel for pending pipelines on branch, if they are not HEAD
added 102 commits
-
5141f184...509ff2ab - 101 commits from branch
gitlab-org:master
- 5b322ef6 - add auto-cancel for pending pipelines on branch, if they are not HEAD
-
5141f184...509ff2ab - 101 commits from branch
added 1 commit
- 01cdbb2f - add auto-cancel for pending pipelines on branch, if they are not HEAD