Skip to content
Snippets Groups Projects

Add Missed SLA label via Cron job

Merged Sean Arnold requested to merge 241663-incident-sla-cron-job into master
All threads resolved!

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 the due_at time has expired, and the corresponding Issue is open.

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

Availability and Testing

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

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Sarah Yasonik
  • Sean Arnold added 7 commits

    added 7 commits

    Compare with previous version

  • Sean Arnold added 27 commits

    added 27 commits

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    • cc37b665 - Add tweaks to worker, service, specs

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Arnold added 453 commits

    added 453 commits

    Compare with previous version

  • assigned to @syasonik

  • assigned to @mbobin

  • unassigned @mbobin

  • Marius Bobin
  • Marius Bobin
  • Marius Bobin
  • Sarah Yasonik
  • Sarah Yasonik
  • Sarah Yasonik
  • Sean Arnold added 12 commits

    added 12 commits

    Compare with previous version

  • Sean Arnold added 10 commits

    added 10 commits

    • 70f0bfea - 1 commit from branch 241663-incident-sla-logic
    • bdbacad5 - Fix import/export models
    • b7dd0826 - Fix typo
    • 9d7f1f7b - Add EE changes to controller for SLA
    • 587d609e - Add exceeded scope to Incident SLA
    • 39085ac5 - Add SLA check cron job
    • df5cbbc0 - Add label system note (resource event)
    • 2bb624bc - Fix spec file name
    • a621b6fb - Add tweaks to worker, service, specs
    • 7e9578db - Use path to create URL

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Arnold added 11 commits

    added 11 commits

    Compare with previous version

  • Sean Arnold added 11 commits

    added 11 commits

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    • 72f53ae7 - Move apply incident label into worker

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    Compare with previous version

  • assigned to @syasonik

  • Sean Arnold assigned to @mbobin and unassigned @syasonik

    assigned to @mbobin and unassigned @syasonik

  • Sean Arnold added 2 commits

    added 2 commits

    • 6e43b28f - Move apply incident label into worker
    • 0216ac22 - Fix issuable sla scope

    Compare with previous version

  • Sean Arnold added 269 commits

    added 269 commits

    Compare with previous version

  • assigned to @syasonik

  • Marius Bobin
  • added databasereviewed label and removed databasereview pending label

  • unassigned @mbobin

  • Sarah Yasonik
  • assigned to @aqualls

  • assigned to @syasonik

  • Sean Arnold added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Arnold added 1 commit

    added 1 commit

    • df9b91a7 - 1 commit from branch 241663-incident-sla-logic

    Compare with previous version

  • Sarah Yasonik changed target branch from 241663-incident-sla-logic to master

    changed target branch from 241663-incident-sla-logic to master

  • Sarah Yasonik approved this merge request

    approved this merge request

  • Sean Arnold added 1 commit

    added 1 commit

    • 821212e0 - Use find_each instead of find_in_batches

    Compare with previous version

  • Sean Arnold added 216 commits

    added 216 commits

    Compare with previous version

  • assigned to @cablett and @tigerwnz

  • Amy Qualls
  • Amy Qualls added 1 commit

    added 1 commit

    • 368169b7 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Amy Qualls approved this merge request

    approved this merge request

  • unassigned @aqualls

  • Tiger Watson approved this merge request

    approved this merge request

  • added databaseapproved label and removed databasereviewed label

  • Sean Arnold added 4 commits

    added 4 commits

    • fd2125dc - Update specs
    • 0dd0f626 - Tweak specs and remove label return
    • 4be60bab - Use find_each instead of find_in_batches
    • 654532de - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • charlie ablett
  • charlie ablett
  • Sean Arnold added 5 commits

    added 5 commits

    • 084cd09f - Update sla label specs
    • 36d910a8 - Tweak specs and remove label return
    • 1f6acbed - Use find_each instead of find_in_batches
    • 59b3d364 - Apply 1 suggestion(s) to 1 file(s)
    • ebbae5d3 - Tweak spec and changelog title

    Compare with previous version

  • charlie ablett resolved all threads

    resolved all threads

  • Sean Arnold marked the checklist item Changelog entry as completed

    marked the checklist item Changelog entry as completed

  • Sean Arnold marked the checklist item Documentation (if required) as completed

    marked the checklist item Documentation (if required) as completed

  • Sean Arnold marked the checklist item Code review guidelines as completed

    marked the checklist item Code review guidelines as completed

  • Sean Arnold marked the checklist item Style guides as completed

    marked the checklist item Style guides as completed

  • Sean Arnold marked the checklist item Separation of EE specific content as completed

    marked the checklist item Separation of EE specific content as completed

  • Sean Arnold marked the checklist item Database guides as completed

    marked the checklist item Database guides as completed

  • Sean Arnold marked the checklist item Merge request performance guidelines as completed

    marked the checklist item Merge request performance guidelines as completed

  • charlie ablett approved this merge request

    approved this merge request

  • Fantastic work @seanarnold ! :rocket:

    Thank you for reviewing @mbobin @tigerwnz @syasonik! :100:

  • charlie ablett enabled an automatic merge when the pipeline for be721a97 succeeds

    enabled an automatic merge when the pipeline for be721a97 succeeds

  • added workflowstaging label and removed workflowin dev label

  • added workflowcanary label and removed workflowstaging label

  • added workflowproduction label and removed workflowcanary label

  • mentioned in issue #241663 (closed)

  • This merge request has been deployed to the pre.gitlab.com environment, and will be included in the upcoming self-managed GitLab 13.5.0 release.


    :robot: This comment is generated automatically using the Release Tools project.

  • This merge request has been deployed to the release.gitlab.net environment, and will be included in the upcoming self-managed GitLab 13.5.0 release.


    :robot: This comment is generated automatically using the Release Tools project.

  • Please register or sign in to reply
    Loading