Add Missed SLA label via Cron job
What does this MR do?
This adds a cron job and related services to add a missed::SLA
label to the incidents which have missed their given SLA times.
To do this we've added a few services:
-
IncidentManagement::CreateIncidentSlaExceededLabelService
- creates the missed::SLA label in the project -
IncidentManagement::ApplyIncidentSlaExceededLabelService
- applies the label to the incidents
This is done via a Cron worker:
IncidentManagement::IncidentSlaExceededCheckWorker
To aid this we've added a new database scope to IndcidentSla
-
IncidentSla.exceeded
- This finds incident SLAs where thedue_at
time has expired, and the corresponding Issue isopen
.
Query for IncidentSla.exceeded
scope:
SELECT "incident_slas".* FROM "incident_slas" INNER JOIN "issues" ON "issues"."id" = "incident_slas"."issue_id" WHERE ("issues"."state_id" IN (1)) AND (due_at < '2020-10-08 05:06:27.511481')
Explain: https://explain.depesz.com/s/SNPr
EXPLAIN for: SELECT "incident_slas".* FROM "incident_slas" INNER JOIN "issues" ON "issues"."id" = "incident_slas"."issue_id" WHERE ("issues"."state_id" IN (1)) AND (due_at < '2020-10-08 05:06:27.511481')
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=23.53..58.28 rows=272 width=16)
Hash Cond: (incident_slas.issue_id = issues.id)
-> Seq Scan on incident_slas (cost=0.00..33.12 rows=617 width=16)
Filter: (due_at < '2020-10-08 05:06:27.511481+00'::timestamp with time zone)
-> Hash (cost=20.91..20.91 rows=210 width=4)
-> Index Only Scan using idx_issues_on_project_id_and_updated_at_and_id_and_state_id on issues (cost=0.27..20.91 rows=210 width=4)
Index Cond: (state_id = 1)
(7 rows)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
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
Related to #241663 (closed)
Edited by Sean Arnold