Add user-friendly message upon runner registration limit
What does this MR do?
This MR is a follow-up to !60157 (merged) in order to improve the error messages shown to the user in case of running against the limit when registering a runner.
Screenshots (strongly suggested)
Current state:
Desired state:
-
Command line:
pry(main)> Plan.default.actual_limits.update!(ci_registered_project_runners: 1)
$ curl --request POST --header "PRIVATE-TOKEN: ${TOKEN}" "http://localhost:3000/api/v4/projects/21/runners" --form "runner_id=24" {"message":{"assign_to":["Validation failed: Maximum number of ci registered project runners (1) exceeded"]}}
Does this MR meet the acceptance criteria?
Conformity
-
Does this MR need a changelog? -
I have included a changelog entry. -
I have not included a changelog entry because it is behind a feature flag.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #321368
Merge request reports
Activity
changed milestone to %13.12
added 2021Q1 gitlab.com Latency Degradation Application Limits Deliverable Technical Writing [Deprecated] Category:Runner backend bugperformance database databaseapproved devopsverify docsfeature documentation feature flag featureenhancement grouprunner infradev priority2 sectionops severity2 typefeature labels
mentioned in merge request !60157 (merged)
requested review from @ayufan
1 Warning featureaddition and featureenhancement merge requests normally have a documentation change. Consider adding a documentation update or confirming the documentation plan with the Technical Writer counterpart.
For more information, see:
- The Handbook page on merge request types.
- The definition of done documentation.
2 Messages CHANGELOG missing: If you want to create a changelog entry for GitLab FOSS, run the following:
bin/changelog -m 61051 "Add user-friendly message upon runner registration limit"
If you want to create a changelog entry for GitLab EE, run the following instead:
bin/changelog --ee -m 61051 "Add user-friendly message upon runner registration limit"
If this merge request doesn't need a CHANGELOG entry, feel free to ignore this message.
We are in the process of rolling out a new workflow for adding changelog entries. This new workflow uses Git commit subjects and Git trailers to generate changelogs. This new approach will soon replace the current YAML based approach. To ease the transition process, we recommend you start using both the old and new approach in parallel. This is not required at this time, but will make it easier to transition to the new approach in the future. To do so, pick the commit that should go in the changelog and add a
Changelog
trailer to it. For example:This is my commit's subject line This is the optional commit body. Changelog: added
The value of the
Changelog
trailer should be one of the following: added, fixed, changed, deprecated, removed, security, performance, other.For more information, take a look at the following resources:
https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564
- https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
If you'd like to see the new approach in action, take a look at the commits in the Omnibus repository.
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
Category Reviewer Maintainer backend Felipe Artur ( @felipe_artur
) (UTC-3, 5 hours behind@pedropombeiro
)Stan Hu ( @stanhu
) (UTC-7, 9 hours behind@pedropombeiro
)database Luis Mejia ( @lmejia2
) (UTC-6, 8 hours behind@pedropombeiro
)Adam Hegyi ( @ahegyi
) (UTC+2, same timezone as@pedropombeiro
)If needed, you can retry the
danger-review
job that generated this comment.Generated by
Danger Edited by 🤖 GitLab Bot 🤖removed Technical Writing label
removed docsfeature label
removed documentation label
removed feature flag label
removed database label
removed databaseapproved label
removed bugperformance label
added 244 commits
-
213fc6ba...eb8a3ed7 - 242 commits from branch
master
- 81b4c839 - Replace error messages in Runner API with more context
- f807afae - Show error message when assigning runner to project
-
213fc6ba...eb8a3ed7 - 242 commits from branch
- Resolved by Matthias Käppler
From what I see does a trick:
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 05126853e0f..6b0c0a57877 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -46,9 +46,9 @@ class Runner < ApplicationRecord MINUTES_COST_FACTOR_FIELDS = %i[public_projects_minutes_cost_factor private_projects_minutes_cost_factor].freeze has_many :builds - has_many :runner_projects, inverse_of: :runner, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :runner_projects, inverse_of: :runner, autosave: true, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :runner_projects - has_many :runner_namespaces, inverse_of: :runner + has_many :runner_namespaces, inverse_of: :runner, autosave: true has_many :groups, through: :runner_namespaces has_one :last_build, -> { order('id DESC') }, class_name: 'Ci::Build'
Result:
=> #<ActiveModel::Errors:0x00007f3e3eb0d690 @base= #<Ci::Runner:0x00007f3e3eaafc20 id: nil, token: nil, created_at: nil, updated_at: nil, description: nil, contacted_at: nil, active: true, name: nil, version: nil, revision: nil, platform: nil, architecture: nil, run_untagged: true, locked: false, access_level: "not_protected", ip_address: nil, maximum_timeout: nil, runner_type: "group_type", token_encrypted: nil, public_projects_minutes_cost_factor: 0.0, private_projects_minutes_cost_factor: 1.0, executor: nil, features: nil, tag_list: nil>, @details={:"runner_namespaces.base"=>[{:error=>"Maximum number of ci registered group runners (1) exceeded"}]}, @messages={:"runner_namespaces.base"=>["Maximum number of ci registered group runners (1) exceeded"]}>
I did not validate if this does not have any negative consequences elsewhere.
Edited by Kamil Trzciński
removed review request for @ayufan
added 487 commits
-
f807afae...74da7a21 - 485 commits from branch
master
- be8e94a6 - Force autosave on project and namespace relationships
- 858cc94e - Show error message when assigning runner to project
-
f807afae...74da7a21 - 485 commits from branch