Create Deployments for processed (ready-to-run) jobs only
Create Deployments for processed (ready-to-run) jobs only
Problem
Currently, we create Deployment for all deployment jobs. Since Deployment is a stateful model, this looks fine at the glance, however, it doesn't make sense to create a Deployment for jobs that are not executable state yet. Because of this, there are some data integrity and UX issues caused, such as:
- Users seeing Deployment Approval even if it's not executable yet.
- Users seeing manual deployment jobs in Environment details page even if it's not executable yet.
- Irrelevant Deployment records in Environment page harms the readability on the page.
Technical side
Basically, there are two steps until a job becomes executable state:
- Create a job. https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/ci/create_pipeline_service.rb. Job status is
created
. - Process a job. https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/ci/pipeline_processing/atomic_processing_service.rb. Job status transitions to
pending
(pickable by runner),manual
(manually executable by user) OR staycreated
if the pipeline pointer hasn't reached the job yet.
Example
You have the following .gitlab-ci.yml
:
stages:
- stage-1
- stage-2
- stage-3
deploy-a:
stage: stage-1
script: echo
environment: prd
when: manual
deploy-b:
stage: stage-2
script: echo
environment: prd
when: manual
deploy-c:
stage: stage-3
script: echo
environment: prd
when: manual
Expected behavior
-
deploy-a
(manual
with deployment) =>deploy-b
(created
w/o deployment) =>deploy-c
(created
w/o deployment) -
deploy-a
(success
with deployment) =>deploy-b
(manual
with deployment) =>deploy-c
(created
w/o deployment) -
deploy-a
(success
with deployment) =>deploy-b
(success
with deployment) =>deploy-c
(manual
with deployment)
Current bug behavior
-
deploy-a
(manual
with deployment) =>deploy-b
(created
with deployment) =>deploy-c
(created
with deployment) -
deploy-a
(success
with deployment) =>deploy-b
(manual
with deployment) =>deploy-c
(created
with deployment) -
deploy-a
(success
with deployment) =>deploy-b
(success
with deployment) =>deploy-c
(manual
with deployment)
Goal
Create Deployment only for processable jobs.
Performance implication
This will slow down the table growth a lot because many jobs are never processed by some reasons (e.g. pipeline stage didn't proceed to deployment). If avoiding to create deployments for such rows is successful, we can proceed with deleting legacy rows with the same condition. This will reduce main database load as described in gitlab#396799 (comment 1328744004).
Related
- Show closed items