Draft: Add auto-generation of iterations for iteration cadences
What does this MR do?
NOTE: this MR is intentionally kept a bit bigger than desired to keep as much context as possible and to give a wider perspective on iteration cadences automation details.
With the above out of the way this MR addresses a couple of iteration and iteration cadence automations:
- Generate iteration cadences in advance for a cadence that is set as automatic.
- This happens in 2 scenarios:
- Cron job running on a daily basis checking for cadences that would potentially need to generate more iterations in advance. LINK TO QUERY.
- Trigger iteration in advance generation when an iteration is being closed and roll-over issues is being attempted. We'll check if the cadence corresponding to the iteration that needs to roll-over issues has a future iteration in place.
- This happens in 2 scenarios:
- Roll-over issues to next iteration if corresponding cadence has the roll-over flag enabled.
- This happens in a sidekiq worker and is triggered when an iteration is closed.
Database
- query generated by
for_automated_iterations
scope
explain
SELECT "iterations_cadences".*
FROM "iterations_cadences"
WHERE "iterations_cadences"."automatic" = TRUE
AND "iterations_cadences"."duration_in_weeks" IS NOT NULL
AND "iterations_cadences"."duration_in_weeks" > 0
AND ("iterations_cadences"."last_run_date" IS NULL
OR DATE (("iterations_cadences"."last_run_date" + "iterations_cadences"."duration_in_weeks" * INTERVAL '1 week')) <= CURRENT_DATE)
Seq Scan on public.iterations_cadences (cost=0.00..229.06 rows=1 width=111) (actual time=0.523..0.523 rows=0 loops=1)
Filter: (iterations_cadences.automatic AND (iterations_cadences.duration_in_weeks IS NOT NULL) AND (iterations_cadences.duration_in_weeks > 0) AND ((iterations_cadences.last_run_date IS NULL) OR (date((iterations_cadences.last_run_date + ((iterations_cadences.duration_in_weeks)::double precision * '7 days'::interval))) <= CURRENT_DATE)))
Rows Removed by Filter: 2379
Buffers: shared hit=41
I/O Timings: read=0.000 write=0.000
Time: 1.172 ms
- planning: 0.612 ms
- execution: 0.560 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 41 (~328.00 KiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
- Adding an index:
exec create index iterations_cadences_automation on iterations_cadences USING btree (automatic, duration_in_weeks, last_run_date)
- query and plan for
for_automated_iterations
scope after index
--same sql
explain
SELECT "iterations_cadences".*
FROM "iterations_cadences"
WHERE "iterations_cadences"."automatic" = TRUE
AND "iterations_cadences"."duration_in_weeks" IS NOT NULL
AND "iterations_cadences"."duration_in_weeks" > 0
AND ("iterations_cadences"."last_run_date" IS NULL
OR DATE (("iterations_cadences"."last_run_date" + "iterations_cadences"."duration_in_weeks" * INTERVAL '1 week')) <= CURRENT_DATE)
--slightly different plan
Index Scan using iterations_cadences_automation on public.iterations_cadences (cost=0.28..100.22 rows=569 width=111) (actual time=0.134..0.612 rows=892 loops=1)
Index Cond: ((iterations_cadences.automatic = false) AND (iterations_cadences.duration_in_weeks IS NOT NULL))
Filter: ((iterations_cadences.last_run_date IS NULL) OR (date((iterations_cadences.last_run_date + ((iterations_cadences.duration_in_weeks)::double precision * '7 days'::interval))) <= CURRENT_DATE))
Rows Removed by Filter: 0
Buffers: shared hit=33 read=5
I/O Timings: read=0.122 write=0.000
Time: 1.393 ms
- planning: 0.699 ms
- execution: 0.694 ms
- I/O read: 0.122 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 33 (~264.00 KiB) from the buffer pool
- reads: 5 (~40.00 KiB) from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
Screenshots (strongly suggested)
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 _____.
-
-
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
Edited by Alexandru Croitor