Skip to content

Add incident label for manually created incident issues

Peter Leitzen requested to merge pl-add-incident-label-for-incidents into master

What does this MR do?

Previously, we've created and applied the "incident" label only when calling the IncidentManagment::Incidents::CreateService explicitly. After we've added the issue type "incident" incidents can be created/updated using the Issues::Create/UpdateService. Those services did not apply this label.

This commit moves the code which applies the label close to the Issue services to make sure we are labeling all incidents with the "incident" label correctly even when creating incident manually using Create Incident button.

Removing the ~incident label from an incident issue has no effect so the label remains attached. No additional system note is created.

Note, this ~bug came up during last meeting and the MR was created before an issues has been created hence the Stuff that should Just Work.


This MR also improves the runtime of Issue::CreateService specs but using let_it_be and before_all where feasible. See !41598 (31895ada).

Contributes to https://gitlab.com/gitlab-org/plan/-/issues/145.

Queries saved: 6121

Click here for details

Before

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:17.153 of 00:42.298 (40.55%)
Total events: 11299

Top 5 slowest suites (by time):

Issues::CreateService (./spec/services/issues/create_service_spec.rb:5) – 00:17.153 (11299 / 56) of 00:42.298 (40.55
%)



Finished in 49.38 seconds (files took 8.96 seconds to load)
56 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 260
 Total top-level: 186
 Total time: 18.1881s
 Total uniq factories: 11

   total   top-level     total time      time per call      top-level time               name

      81          81        3.4816s            0.0430s             3.4816s               user
      56          46       11.2499s            0.2009s             9.7420s            project
      56           0        2.8766s            0.0514s             0.0000s          namespace
      25          25        0.3407s            0.0136s             0.3407s              label
      12          12        0.4799s            0.0400s             0.4799s          milestone
      10          10        0.0625s            0.0063s             0.0625s           spam_log
       8           8        3.9828s            0.4978s             3.9828s diff_note_on_merge_request
       8           0        1.8966s            0.2371s             0.0000s      merge_request
       2           2        0.0278s            0.0139s             0.0278s        group_label
       1           1        0.0109s            0.0109s             0.0109s            license
       1           1        0.0599s            0.0599s             0.0599s              group

After

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:07.897 of 00:24.286 (32.52%)
Total events: 5178

Top 5 slowest suites (by time):

Issues::CreateService (./spec/services/issues/create_service_spec.rb:5) – 00:07.897 (5178 / 56) of 00:24.286 (32.52%
)



Finished in 31.46 seconds (files took 8.4 seconds to load)
56 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 43
 Total top-level: 34
 Total time: 3.8327s
 Total uniq factories: 11

   total   top-level     total time      time per call      top-level time               name

      10          10        0.0728s            0.0073s             0.0728s           spam_log
       7           7        0.5086s            0.0727s             0.5086s               user
       7           7        0.2735s            0.0391s             0.2735s              label
       5           2        2.1495s            0.4299s             1.4504s            project
       5           0        0.3618s            0.0724s             0.0000s          namespace
       3           3        0.5561s            0.1854s             0.5561s          milestone
       2           2        0.0265s            0.0132s             0.0265s        group_label
       1           1        0.0111s            0.0111s             0.0111s            license
       1           1        0.0652s            0.0652s             0.0652s              group
       1           1        0.8686s            0.8686s             0.8686s diff_note_on_merge_request
       1           0        0.5602s            0.5602s             0.0000s      merge_request

Screenshots

Creating an issue Creating an incident
Screenshot_from_2020-09-14_00-22-01 Screenshot_from_2020-09-14_00-22-24

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
Edited by Peter Leitzen

Merge request reports