Shorten error messages for escalation rule count and fix edge case
What does this MR do?
Context
This MR relates to the Category:Incident Management feature set, specifically on-call schedule management and escalation policies. These allow users to route notifications regarding system alerts to the right people, by defining "Escalation Rules".
- On-call schedules are live: https://docs.gitlab.com/ee/operations/incident_management/oncall_schedules.html
- Escalation policies are close to rolling out, but are still behind the
escalation_policies_mvc
feature flag: &4638 - Demo projects: https://gitlab.com/gitlab-examples/ops/incident-setup/everyone/tanuki-inc/-/oncall_schedules, https://staging.gitlab.com/gitlab-org/monitor/monitor-sandbox/-/escalation_policies
Changes
This refactors the error handling for the upper limit of escalation rules per policy, moving the check from the model validations into the create/update services.
- this brings the error message earlier in the flow, so we don't try to create all of the new escalation rules individually
- trying to create each rule takes unneeded time, and results in an error-per-rule, instead of a single error
- there was something funky in the logic of the validation, causing it to behave inconsistently
- I was able to create >10 rules for a policy, as well as blocked with <10 (all during policy edits) - I'm still not entirely sure why, but moving the logic simplifies it
Screenshots or Screencasts (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) - [-] I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?)
-
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) - [x?] I have followed the style guides.
-
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
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
Edited by Sarah Yasonik